[pbs-devel] [PATCH proxmox-backup-qemu 2/2] commands: rename helper to get archive name from device name

Christian Ebner c.ebner at proxmox.com
Tue Jan 28 16:09:07 CET 2025


Rename the helper method to get the archive name from a device name
to reduce possible miss-use. The helper adds a `.img.fidx` filename
extension uncoditionally before parsing the `BackupArchiveName`.

No functional changes intended.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 src/backup.rs   | 3 ++-
 src/commands.rs | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/backup.rs b/src/backup.rs
index 32037ce..e8a0528 100644
--- a/src/backup.rs
+++ b/src/backup.rs
@@ -234,7 +234,8 @@ impl BackupTask {
     pub fn check_incremental(&self, device_name: String, size: u64) -> bool {
         match self.last_manifest() {
             Some(ref manifest) => {
-                let archive_name = if let Ok(archive) = archive_name(&device_name) {
+                let archive_name = if let Ok(archive) = archive_name_from_device_name(&device_name)
+                {
                     archive
                 } else {
                     return false;
diff --git a/src/commands.rs b/src/commands.rs
index 22e7135..565649f 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -120,7 +120,7 @@ pub(crate) async fn add_config(
     Ok(0)
 }
 
-pub(crate) fn archive_name(device_name: &str) -> Result<BackupArchiveName, Error> {
+pub(crate) fn archive_name_from_device_name(device_name: &str) -> Result<BackupArchiveName, Error> {
     format!("{}.img.fidx", device_name).parse()
 }
 
@@ -191,7 +191,7 @@ pub(crate) async fn register_image(
     chunk_size: u64,
     incremental: bool,
 ) -> Result<c_int, Error> {
-    let archive_name: BackupArchiveName = archive_name(&device_name)?;
+    let archive_name: BackupArchiveName = archive_name_from_device_name(&device_name)?;
 
     let index = match manifest {
         Some(manifest) => {
@@ -328,7 +328,7 @@ pub(crate) async fn close_image(
 
     let mut guard = manifest.lock().unwrap();
     guard.add_file(
-        &archive_name(&device_name)?,
+        &archive_name_from_device_name(&device_name)?,
         device_size,
         upload_result.csum,
         crypt_mode,
-- 
2.39.5





More information about the pbs-devel mailing list