From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 1/2] pull: decrypt: use let else to reduce indentation
Date: Fri, 24 Apr 2026 14:46:08 +0200 [thread overview]
Message-ID: <20260424124615.654666-1-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20260424103607.531400-1-c.ebner@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
best viewed with -w
src/server/pull.rs | 56 +++++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 30 deletions(-)
diff --git a/src/server/pull.rs b/src/server/pull.rs
index d0f886cb5..3dc5770f9 100644
--- a/src/server/pull.rs
+++ b/src/server/pull.rs
@@ -926,48 +926,44 @@ async fn optionally_use_decryption_key(
prefix: String,
log_sender: Arc<LogLineSender>,
) -> Result<(Option<Arc<CryptConfig>>, bool), Error> {
- let key_fp = match manifest.fingerprint().with_context(|| prefix.clone())? {
- Some(key_fp) => key_fp,
- None => return Ok((None, false)), // no fingerprint on source, regular pull
+ let Some(key_fp) = manifest.fingerprint().with_context(|| prefix.clone())? else {
+ return Ok((None, false)); // no fingerprint on source, regular pull
};
// source got key fingerprint, expect contents to be signed or encrypted
- let (key_id, config) = match params
+ let Some((key_id, config)) = params
.crypt_configs
.iter()
.find(|(_id, crypt_conf)| crypt_conf.fingerprint() == *key_fp.bytes())
- {
- Some(key_id_and_config) => key_id_and_config,
- None => {
- // no matching key found in list of configured ones
- if let Some(existing_target_manifest) = existing_target_manifest {
- if let Some(existing_fingerprint) = existing_target_manifest
- .fingerprint()
- .with_context(|| prefix.clone())?
- {
- if existing_fingerprint != key_fp {
- // pre-existing local manifest for encrypted snapshot with key mismatch
- bail!(
+ else {
+ // no matching key found in list of configured ones
+ if let Some(existing_target_manifest) = existing_target_manifest {
+ if let Some(existing_fingerprint) = existing_target_manifest
+ .fingerprint()
+ .with_context(|| prefix.clone())?
+ {
+ if existing_fingerprint != key_fp {
+ // pre-existing local manifest for encrypted snapshot with key mismatch
+ bail!(
"Local encrypted or signed snapshot with different key detected, refuse to sync"
);
- }
- } else {
- // pre-existing local manifest without key-fingerprint was previously decrypted,
- // never overwrite with encrypted
- bail!(
+ }
+ } else {
+ // pre-existing local manifest without key-fingerprint was previously decrypted,
+ // never overwrite with encrypted
+ bail!(
"local snapshot was previously decrypted but no matching decryption key is configured, refuse to sync"
);
- }
- } else if !params.crypt_configs.is_empty() {
- log_sender
- .log(
- Level::INFO,
- format!("{prefix}: No matching key found, sync without decryption"),
- )
- .await?;
}
- return Ok((None, false));
+ } else if !params.crypt_configs.is_empty() {
+ log_sender
+ .log(
+ Level::INFO,
+ format!("{prefix}: No matching key found, sync without decryption"),
+ )
+ .await?;
}
+ return Ok((None, false));
};
// check if source is encrypted or contents signed
--
2.47.3
next prev parent reply other threads:[~2026-04-24 12:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 10:36 [PATCH proxmox-backup 0/3] fixup for server side decryption Christian Ebner
2026-04-24 10:36 ` [PATCH proxmox-backup 1/3] sync: pull decrypt: check if contents only signed or fully encrypted Christian Ebner
2026-04-24 10:36 ` [PATCH proxmox-backup 2/3] sync: pull: refactor decryption key loading checks Christian Ebner
2026-04-24 12:46 ` Fabian Grünbichler
2026-04-24 10:36 ` [PATCH proxmox-backup 3/3] api: encryption keys: refactor associated keys check Christian Ebner
2026-04-24 12:46 ` Fabian Grünbichler [this message]
2026-04-24 12:46 ` [PATCH proxmox-backup 2/2] pull: decrypt: re-order encryption key/state checks Fabian Grünbichler
2026-04-24 19:06 ` applied: [PATCH proxmox-backup 0/3] fixup for server side decryption Thomas Lamprecht
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=20260424124615.654666-1-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