[pbs-devel] [PATCH proxmox-backup 2/2] pbs-client: fix unnecessary unwrap

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Nov 3 10:33:34 CET 2025


detected by clippy, but not auto-fixable.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---

Notes:
    with edition 2024, the nested ifs could be combined again - but that requires
    more changes and would also make backporting to PBS 3 harder..

    best viewed with -w

 pbs-client/src/http_client.rs | 55 +++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs
index 8bddf8940..4599bf226 100644
--- a/pbs-client/src/http_client.rs
+++ b/pbs-client/src/http_client.rs
@@ -425,11 +425,11 @@ impl HttpClient {
                 ) {
                     Ok(None) => true,
                     Ok(Some(fingerprint)) => {
-                        if fingerprint_cache && prefix.is_some() {
-                            if let Err(err) =
-                                store_fingerprint(prefix.as_ref().unwrap(), &server, &fingerprint)
-                            {
-                                error!("{}", err);
+                        if fingerprint_cache {
+                            if let Some(ref prefix) = prefix {
+                                if let Err(err) = store_fingerprint(prefix, &server, &fingerprint) {
+                                    error!("{}", err);
+                                }
                             }
                         }
                         *verified_fingerprint.lock().unwrap() = Some(fingerprint);
@@ -535,16 +535,18 @@ impl HttpClient {
                 .await
                 {
                     Ok(auth) => {
-                        if use_ticket_cache && prefix2.is_some() {
-                            if let Err(err) = store_ticket_info(
-                                prefix2.as_ref().unwrap(),
-                                &server2,
-                                &auth.auth_id.to_string(),
-                                &auth.ticket,
-                                &auth.token,
-                            ) {
-                                if std::io::stdout().is_terminal() {
-                                    error!("storing login ticket failed: {}", err);
+                        if use_ticket_cache {
+                            if let Some(ref prefix) = prefix2 {
+                                if let Err(err) = store_ticket_info(
+                                    prefix,
+                                    &server2,
+                                    &auth.auth_id.to_string(),
+                                    &auth.ticket,
+                                    &auth.token,
+                                ) {
+                                    if std::io::stdout().is_terminal() {
+                                        error!("storing login ticket failed: {}", err);
+                                    }
                                 }
                             }
                         }
@@ -572,19 +574,22 @@ impl HttpClient {
             let authinfo = auth.clone();
 
             move |auth| {
-                if use_ticket_cache && prefix.is_some() {
-                    if let Err(err) = store_ticket_info(
-                        prefix.as_ref().unwrap(),
-                        &server,
-                        &auth.auth_id.to_string(),
-                        &auth.ticket,
-                        &auth.token,
-                    ) {
-                        if std::io::stdout().is_terminal() {
-                            error!("storing login ticket failed: {}", err);
+                if use_ticket_cache {
+                    if let Some(ref prefix) = prefix {
+                        if let Err(err) = store_ticket_info(
+                            prefix,
+                            &server,
+                            &auth.auth_id.to_string(),
+                            &auth.ticket,
+                            &auth.token,
+                        ) {
+                            if std::io::stdout().is_terminal() {
+                                error!("storing login ticket failed: {}", err);
+                            }
                         }
                     }
                 }
+
                 *authinfo.write().unwrap() = auth;
                 tokio::spawn(renewal_future);
             }
-- 
2.47.3





More information about the pbs-devel mailing list