From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] pbs-client: fix unnecessary unwrap
Date: Mon,  3 Nov 2025 10:33:34 +0100	[thread overview]
Message-ID: <20251103093437.214556-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20251103093437.214556-1-f.gruenbichler@proxmox.com>
detected by clippy, but not auto-fixable.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@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
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
     prev parent reply	other threads:[~2025-11-03  9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03  9:33 [pbs-devel] [PATCH proxmox-backup 1/2] tree-wide: make hidden lifetimes explicit Fabian Grünbichler
2025-11-03  9:33 ` Fabian Grünbichler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=20251103093437.214556-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox