From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 3C5251FF38E for ; Tue, 14 May 2024 12:34:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5258B3BBD; Tue, 14 May 2024 12:34:52 +0200 (CEST) From: Christian Ebner To: pbs-devel@lists.proxmox.com Date: Tue, 14 May 2024 12:33:34 +0200 Message-Id: <20240514103421.289431-19-c.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514103421.289431-1-c.ebner@proxmox.com> References: <20240514103421.289431-1-c.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 Subject: [pbs-devel] [PATCH v6 proxmox-backup 18/65] client: pxar: add optional pxar payload writer instance 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" Extend the PxarWriters to hold the optional pxar payload writer and attach it to the pxar encoder during archive creation. The payload writer will encode the payloads of regular files to a different backup stream, splitting the metadata from the payload data. Signed-off-by: Christian Ebner --- pbs-client/src/pxar/create.rs | 20 ++++++++++++++++--- pbs-client/src/pxar_backup_stream.rs | 2 +- .../src/proxmox_restore_daemon/api.rs | 10 ++++++++-- pxar-bin/src/main.rs | 2 +- tests/catar.rs | 2 +- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index 82f05889b..2bb5a6253 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -137,12 +137,21 @@ type Encoder<'a, T> = pxar::encoder::aio::Encoder<'a, T>; pub struct PxarWriters { writer: T, + payload_writer: Option, catalog: Option>>, } impl PxarWriters { - pub fn new(writer: T, catalog: Option>>) -> Self { - Self { writer, catalog } + pub fn new( + writer: T, + payload_writer: Option, + catalog: Option>>, + ) -> Self { + Self { + writer, + payload_writer, + catalog, + } } } @@ -180,7 +189,12 @@ where set.insert(stat.st_dev); } - let mut encoder = Encoder::new(&mut writers.writer, &metadata, None).await?; + let mut encoder = Encoder::new( + &mut writers.writer, + &metadata, + writers.payload_writer.as_mut(), + ) + .await?; let mut patterns = options.patterns; diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs index bfa108a8b..cdfb7eaa8 100644 --- a/pbs-client/src/pxar_backup_stream.rs +++ b/pbs-client/src/pxar_backup_stream.rs @@ -58,7 +58,7 @@ impl PxarBackupStream { let writer = pxar::encoder::sync::StandardWriter::new(writer); if let Err(err) = crate::pxar::create_archive( dir, - PxarWriters::new(writer, Some(catalog)), + PxarWriters::new(writer, None, Some(catalog)), crate::pxar::Flags::DEFAULT, move |path| { log::debug!("{:?}", path); diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs index 1ee200573..ea97976e6 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs @@ -358,8 +358,14 @@ fn extract( }; let pxar_writer = TokioWriter::new(writer); - create_archive(dir, PxarWriters::new(pxar_writer, None), Flags::DEFAULT, |_| Ok(()), options) - .await + create_archive( + dir, + PxarWriters::new(pxar_writer, None, None), + Flags::DEFAULT, + |_| Ok(()), + options, + ) + .await } .await; if let Err(err) = result { diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs index ae2325078..34944cf16 100644 --- a/pxar-bin/src/main.rs +++ b/pxar-bin/src/main.rs @@ -377,7 +377,7 @@ async fn create_archive( let writer = pxar::encoder::sync::StandardWriter::new(writer); pbs_client::pxar::create_archive( dir, - PxarWriters::new(writer, None), + PxarWriters::new(writer, None, None), feature_flags, move |path| { log::debug!("{:?}", path); diff --git a/tests/catar.rs b/tests/catar.rs index f414da8c9..9e96a8610 100644 --- a/tests/catar.rs +++ b/tests/catar.rs @@ -35,7 +35,7 @@ fn run_test(dir_name: &str) -> Result<(), Error> { let rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(create_archive( dir, - PxarWriters::new(writer, None), + PxarWriters::new(writer, None, None), Flags::DEFAULT, |_| Ok(()), options, -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel