[pbs-devel] [PATCH v9 proxmox-backup 06/58] client: tools: helper to check pxar filename extensions

Christian Ebner c.ebner at proxmox.com
Wed Jun 5 12:53:24 CEST 2024


With the introduction of split pxar archives, the allowed extensions
are now `.pxar`, `.mpxar` and `.ppxar`. Add a helper function to
allow to check for all valid variants, including the optional
additional `.didx` in case of a server archive name.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 8:
- no changes

 pbs-client/src/tools/mod.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs
index fdce33914..67768fa5c 100644
--- a/pbs-client/src/tools/mod.rs
+++ b/pbs-client/src/tools/mod.rs
@@ -576,3 +576,16 @@ pub fn get_pxar_archive_names(
 
     bail!("archive not found in manifest");
 }
+
+/// Check if the given filename has a valid pxar filename extension variant
+///
+/// If `with_didx_extension` is `true`, check the additional `.didx` ending.
+pub fn has_pxar_filename_extension(name: &str, with_didx_extension: bool) -> bool {
+    if with_didx_extension {
+        name.ends_with(".pxar.didx")
+            || name.ends_with(".mpxar.didx")
+            || name.ends_with(".ppxar.didx")
+    } else {
+        name.ends_with(".pxar") || name.ends_with(".mpxar") || name.ends_with(".ppxar")
+    }
+}
-- 
2.39.2





More information about the pbs-devel mailing list