[pbs-devel] [PATCH v5 proxmox-backup 21/62] client: helper: add method for split archive name mapping
Christian Ebner
c.ebner at proxmox.com
Tue May 7 17:52:03 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>
---
changes since version 4:
- no changes
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