[pbs-devel] [PATCH v4 proxmox-backup 21/58] client: helper: add method for split archive name mapping

Christian Ebner c.ebner at proxmox.com
Mon Apr 29 14:10:25 CEST 2024


Helper method that takes the meta or payload archive name as input
and maps it to the correct archive names for metadata and payload
archive.

If neighter is matched, fallback to returning the passed in archive
name as target archive and `None` for the payload archive name.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 proxmox-backup-client/src/helper.rs | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/proxmox-backup-client/src/helper.rs b/proxmox-backup-client/src/helper.rs
index 00b3ce362..f55231ce2 100644
--- a/proxmox-backup-client/src/helper.rs
+++ b/proxmox-backup-client/src/helper.rs
@@ -73,3 +73,24 @@ pub(crate) async fn get_buffered_pxar_reader(
 
     Ok(BufferedDynamicReader::new(index, chunk_reader))
 }
+
+pub(crate) fn get_pxar_archive_names(archive_name: &str) -> (String, Option<String>) {
+    if let Some(base) = archive_name
+        .strip_suffix(".mpxar.didx")
+        .or_else(|| archive_name.strip_suffix(".ppxar.didx"))
+    {
+        return (
+            format!("{base}.mpxar.didx"),
+            Some(format!("{base}.ppxar.didx")),
+        );
+    }
+
+    if let Some(base) = archive_name
+        .strip_suffix(".mpxar")
+        .or_else(|| archive_name.strip_suffix(".ppxar"))
+    {
+        return (format!("{base}.mpxar"), Some(format!("{base}.ppxar")));
+    }
+
+    (archive_name.to_owned(), None)
+}
-- 
2.39.2





More information about the pbs-devel mailing list