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

Christian Ebner c.ebner at proxmox.com
Thu Mar 28 13:36:31 CET 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>
---
changes since version 2:
- not present in previous version

 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 cb58db2a6..864bdd737 100644
--- a/proxmox-backup-client/src/helper.rs
+++ b/proxmox-backup-client/src/helper.rs
@@ -41,3 +41,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