[pbs-devel] [PATCH proxmox-backup 1/3] pxar: factor out encode_file

Gabriel Goller g.goller at proxmox.com
Wed Mar 6 15:34:11 CET 2024


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 at 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





More information about the pbs-devel mailing list