From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 824AB1FF0C2 for ; Thu, 03 Dec 2026 16:05:10 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 9036E21783; Thu, 03 Dec 2026 16:05:09 +0100 (CET) From: Christian Ebner To: pbs-devel@lists.proxmox.com Subject: [PATCH v2 proxmox-backup 4/9] server: pull: move target manifest loading logic into reusable helper Date: Thu, 3 Dec 2026 16:04:43 +0100 Message-ID: <20261203150448.412515-5-c.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203150448.412515-1-c.ebner@proxmox.com> References: <20261203150448.412515-1-c.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1796310301211 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.334 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 3LQQOTIKJIDDUC2W5M6ONHMYDIOIRNN5 X-Message-ID-Hash: 3LQQOTIKJIDDUC2W5M6ONHMYDIOIRNN5 X-MailFrom: c.ebner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Extract the local manifest reading and parsing from pull_snapshot() into a dedicated load_target_manifest() helper. In preparation for checking snapshots being unchanged since the last sync under a shared instead of exclusive lock. No functional changes. Signed-off-by: Christian Ebner --- src/server/pull.rs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/server/pull.rs b/src/server/pull.rs index 5ab47ac3f..308ac752b 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -3,6 +3,7 @@ use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::io::Seek; +use std::path::Path; use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex}; use std::time::{Duration, SystemTime}; @@ -613,6 +614,23 @@ async fn pull_single_archive<'a>( Ok(sync_stats) } +fn load_target_manifest(manifest_name: &Path, prefix: &str) -> Result { + let manifest_blob = proxmox_lang::try_block!({ + let mut manifest_file = std::fs::File::open(manifest_name).map_err(|err| { + format_err!("{prefix}: unable to open local manifest {manifest_name:?} - {err}") + })?; + + let manifest_blob = + DataBlob::load_from_reader(&mut manifest_file).with_context(|| prefix.to_owned())?; + Ok(manifest_blob) + }) + .map_err(|err: Error| { + format_err!("{prefix}: unable to read local manifest {manifest_name:?} - {err}") + })?; + + BackupManifest::try_from(manifest_blob).with_context(|| prefix.to_owned()) +} + /// Actual implementation of pulling a snapshot. /// /// Pulling a snapshot consists of the following steps: @@ -690,21 +708,7 @@ async fn pull_snapshot<'a>( let mut manifest = BackupManifest::try_from(manifest_blob).with_context(|| prefix.clone())?; let existing_target_manifest = if manifest_name.exists() && !corrupt { - let manifest_blob = proxmox_lang::try_block!({ - let mut manifest_file = std::fs::File::open(&manifest_name).map_err(|err| { - format_err!("{prefix}: unable to open local manifest {manifest_name:?} - {err}") - })?; - - let manifest_blob = - DataBlob::load_from_reader(&mut manifest_file).with_context(|| prefix.clone())?; - Ok(manifest_blob) - }) - .map_err(|err: Error| { - format_err!("{prefix}: unable to read local manifest {manifest_name:?} - {err}") - })?; - - let existing_manifest = - BackupManifest::try_from(manifest_blob).with_context(|| prefix.clone())?; + let existing_manifest = load_target_manifest(&manifest_name, &prefix)?; // the target never inherits the source's verify state (see below), so a manifest that // only differs in it means the snapshot did not change since it was last synced -- 2.47.3