public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/3] pxar: factor out encode_file
Date: Wed,  6 Mar 2024 15:34:11 +0100	[thread overview]
Message-ID: <20240306143422.114335-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20240306143422.114335-1-g.goller@proxmox.com>

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 <g.goller@proxmox.com>
---
 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<T: SeqWrite + Send>(
+        &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





  reply	other threads:[~2024-03-06 14:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 14:34 [pbs-devel] [RFC proxmox-backup 0/3] Encode creation parameters into pxar archive Gabriel Goller
2024-03-06 14:34 ` Gabriel Goller [this message]
2024-03-06 14:34 ` [pbs-devel] [PATCH proxmox-backup 2/3] client: unify parameters and write to file Gabriel Goller
2024-03-06 14:34 ` [pbs-devel] [PATCH proxmox-backup 3/3] pxar: added creation parameters Gabriel Goller
2024-03-06 15:13 ` [pbs-devel] [RFC proxmox-backup 0/3] Encode creation parameters into pxar archive Christian Ebner
2024-03-07  9:22   ` Gabriel Goller
2024-03-07  9:50   ` 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=20240306143422.114335-2-g.goller@proxmox.com \
    --to=g.goller@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal