From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 13ED997EE7 for ; Wed, 6 Mar 2024 15:34:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E6C401A513 for ; Wed, 6 Mar 2024 15:34:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 6 Mar 2024 15:34:29 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1587548851 for ; Wed, 6 Mar 2024 15:34:29 +0100 (CET) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Wed, 6 Mar 2024 15:34:11 +0100 Message-ID: <20240306143422.114335-2-g.goller@proxmox.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240306143422.114335-1-g.goller@proxmox.com> References: <20240306143422.114335-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.096 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 - Subject: [pbs-devel] [PATCH proxmox-backup 1/3] pxar: factor out encode_file 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: , X-List-Received-Date: Wed, 06 Mar 2024 14:34:30 -0000 When writing the `--exclude` params to the '.pxarexclude-cli' file, we use a function `encode_pxarexclude_cli`. Factored it out, so we can use it for other files as well. Signed-off-by: Gabriel Goller --- pbs-client/src/pxar/create.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index 60efb0ce..0d5e8b68 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -395,6 +395,16 @@ impl Archiver { patterns_count: usize, ) -> Result<(), Error> { let content = generate_pxar_excludes_cli(&self.patterns[..patterns_count]); + self.encode_file(encoder, file_name, &content).await?; + Ok(()) + } + + async fn encode_file( + &mut self, + encoder: &mut Encoder<'_, T>, + file_name: &CStr, + content: &[u8], + ) -> Result<(), Error> { if let Some(ref catalog) = self.catalog { catalog .lock() @@ -406,9 +416,9 @@ impl Archiver { metadata.stat.mode = pxar::format::mode::IFREG | 0o600; let mut file = encoder - .create_file(&metadata, ".pxarexclude-cli", content.len() as u64) + .create_file(&metadata, file_name.to_str()?, content.len() as u64) .await?; - file.write_all(&content).await?; + file.write_all(content).await?; Ok(()) } -- 2.43.0