From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 4163D1FF38F for ; Tue, 4 Jun 2024 10:16:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2A912C147; Tue, 4 Jun 2024 10:17:17 +0200 (CEST) Date: Tue, 04 Jun 2024 10:17:10 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20240528094303.309806-1-c.ebner@proxmox.com> <20240528094303.309806-23-c.ebner@proxmox.com> In-Reply-To: <20240528094303.309806-23-c.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1717488275.2cwfq6fty5.astroid@yuna.none> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, helper.rs] Subject: Re: [pbs-devel] [PATCH v8 proxmox-backup 22/69] client: helper: add method for split archive name mapping X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" On May 28, 2024 11:42 am, Christian Ebner wrote: > Helper method that takes the meta or payload archive name as input > and maps it to the correct archive names for metadata and payload > archive. > > If neither is matched, fallback to returning the passed in archive > name as target archive and `None` for the payload archive name. > > Signed-off-by: Christian Ebner > --- > changes since version 7: > - no changes > > changes since version 6: > - extend mapping to also include `.pxar` as allowed extension, mapping > to `.mpxar` > > proxmox-backup-client/src/helper.rs | 42 +++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/proxmox-backup-client/src/helper.rs b/proxmox-backup-client/src/helper.rs > index 5b21b6720..5589aa5b1 100644 > --- a/proxmox-backup-client/src/helper.rs > +++ b/proxmox-backup-client/src/helper.rs > @@ -70,3 +70,45 @@ pub(crate) async fn get_buffered_pxar_reader( > > Ok(BufferedDynamicReader::new(index, chunk_reader)) > } > + > +pub(crate) fn get_pxar_archive_names( > + archive_name: &str, > + manifest: &BackupManifest, > +) -> (String, Option) { > + let filename = archive_name.strip_suffix(".didx").unwrap_or(archive_name); > + > + if let Some(base) = filename > + .strip_suffix(".mpxar") > + .or_else(|| filename.strip_suffix(".ppxar")) > + { > + if archive_name.ends_with(".didx") { > + return ( > + format!("{base}.mpxar.didx"), > + Some(format!("{base}.ppxar.didx")), > + ); > + } else { > + return (format!("{base}.mpxar"), Some(format!("{base}.ppxar"))); > + } > + } > + > + if let Some(base) = filename.strip_suffix(".pxar") { > + // Check if pxar is present, otherwise fallback to split archive naming > + if manifest > + .files() > + .iter() > + .find(|fileinfo| fileinfo.filename == filename) > + .is_none() > + { I know why this is here, but the behaviour of this helper is now in a weird half-way state of checking but not really. currently it's called for various restore-type operations (where passing in an archive that is not found in any variation is an error anyway) and for preparing the reference for an incremental backup, where the result is an option. so could this helper not be changed to check whether the desired archive is referenced by the manifest (including the fallback to split archive when given a regular pxar archive name) and return None otherwise? or a Result, and the incremental case would catch and log it, but (obviously) not treat it as fatal, while the others would? > + if archive_name.ends_with(".didx") { > + return ( > + format!("{base}.mpxar.didx"), > + Some(format!("{base}.ppxar.didx")), > + ); > + } else { > + return (format!("{base}.mpxar"), Some(format!("{base}.ppxar"))); > + } > + } > + } > + > + (archive_name.to_owned(), None) > +} > -- > 2.39.2 > > > > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel > > > _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel