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

Christian Ebner c.ebner at proxmox.com
Tue May 14 12:33:37 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 neither 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