public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 02/13] use inspect_err when possible
Date: Mon,  2 Dec 2024 10:57:57 +0100	[thread overview]
Message-ID: <20241202095808.128299-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20241202095808.128299-1-m.sandoval@proxmox.com>

Fixes the manual_inspect clippy lint:

```
warning: using `map_err` over `inspect_err`
   --> src/bin/proxmox_backup_debug/diff.rs:125:18
    |
125 |                 .map_err(|err| {
    |                  ^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
    = note: `#[warn(clippy::manual_inspect)]` on by default
help: try
    |
125 ~                 .inspect_err(|err| {
126 ~                     log::error!("{}", format_key_source(&key.source, "encryption"));
    |
```

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-backup-client/src/catalog.rs | 6 ++----
 proxmox-backup-client/src/main.rs    | 3 +--
 proxmox-file-restore/src/main.rs     | 6 ++----
 src/bin/proxmox_backup_debug/diff.rs | 3 +--
 4 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/proxmox-backup-client/src/catalog.rs b/proxmox-backup-client/src/catalog.rs
index 7173c8efc..473214c35 100644
--- a/proxmox-backup-client/src/catalog.rs
+++ b/proxmox-backup-client/src/catalog.rs
@@ -65,9 +65,8 @@ async fn dump_catalog(param: Value) -> Result<Value, Error> {
         None => None,
         Some(key) => {
             let (key, _created, _fingerprint) = decrypt_key(&key.key, &get_encryption_key_password)
-                .map_err(|err| {
+                .inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             let crypt_config = CryptConfig::new(key)?;
             Some(Arc::new(crypt_config))
@@ -204,9 +203,8 @@ async fn catalog_shell(param: Value) -> Result<(), Error> {
         None => None,
         Some(key) => {
             let (key, _created, _fingerprint) = decrypt_key(&key.key, &get_encryption_key_password)
-                .map_err(|err| {
+                .inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             let crypt_config = CryptConfig::new(key)?;
             Some(Arc::new(crypt_config))
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 580feb626..c9be952ad 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -1543,9 +1543,8 @@ async fn restore(
         None => None,
         Some(ref key) => {
             let (key, _, _) =
-                decrypt_key(&key.key, &get_encryption_key_password).map_err(|err| {
+                decrypt_key(&key.key, &get_encryption_key_password).inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             Some(Arc::new(CryptConfig::new(key)?))
         }
diff --git a/proxmox-file-restore/src/main.rs b/proxmox-file-restore/src/main.rs
index 0a60d69f6..bbfc6eb4e 100644
--- a/proxmox-file-restore/src/main.rs
+++ b/proxmox-file-restore/src/main.rs
@@ -291,9 +291,8 @@ async fn list(
         None => None,
         Some(ref key) => {
             let (key, _, _) =
-                decrypt_key(&key.key, &get_encryption_key_password).map_err(|err| {
+                decrypt_key(&key.key, &get_encryption_key_password).inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             Some(Arc::new(CryptConfig::new(key)?))
         }
@@ -455,9 +454,8 @@ async fn extract(
         None => None,
         Some(ref key) => {
             let (key, _, _) =
-                decrypt_key(&key.key, &get_encryption_key_password).map_err(|err| {
+                decrypt_key(&key.key, &get_encryption_key_password).inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             Some(Arc::new(CryptConfig::new(key)?))
         }
diff --git a/src/bin/proxmox_backup_debug/diff.rs b/src/bin/proxmox_backup_debug/diff.rs
index dcd351d93..02389d0e5 100644
--- a/src/bin/proxmox_backup_debug/diff.rs
+++ b/src/bin/proxmox_backup_debug/diff.rs
@@ -122,9 +122,8 @@ async fn diff_archive_cmd(
         None => None,
         Some(key) => {
             let (key, _created, _fingerprint) = decrypt_key(&key.key, &get_encryption_key_password)
-                .map_err(|err| {
+                .inspect_err(|_err| {
                     log::error!("{}", format_key_source(&key.source, "encryption"));
-                    err
                 })?;
             let crypt_config = CryptConfig::new(key)?;
             Some(Arc::new(crypt_config))
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2024-12-02  9:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02  9:57 [pbs-devel] [PATCH backup 01/13] remove needless borrows Maximiliano Sandoval
2024-12-02  9:57 ` Maximiliano Sandoval [this message]
2024-12-02  9:57 ` [pbs-devel] [PATCH backup 03/13] backup_manager: use Vec::first instead of get(0) Maximiliano Sandoval
2024-12-02  9:57 ` [pbs-devel] [PATCH backup 04/13] push: use unwrap_or to prevent lazy evaluation Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 05/13] docs: use sublist indentation Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 06/13] client: remove unnecessary deref Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 07/13] remove needless type conversion Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 08/13] client: catalog: remove unnecessary sort_unstable_by Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 09/13] docs: fix outer docs comments Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 10/13] remove redundant imports Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 11/13] restore_daemon: use map_while instead of filter_map(Result::ok) Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 12/13] datastore: simplify let-else block with ? operator Maximiliano Sandoval
2024-12-02  9:58 ` [pbs-devel] [PATCH backup 13/13] api: config: run rustfmt Maximiliano Sandoval
2024-12-02 11:20 ` [pbs-devel] applied-series: [PATCH backup 01/13] remove needless borrows Fabian Grünbichler

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=20241202095808.128299-2-m.sandoval@proxmox.com \
    --to=m.sandoval@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal