public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup-qemu 2/2] commands: rename helper to get archive name from device name
Date: Tue, 28 Jan 2025 16:09:07 +0100	[thread overview]
Message-ID: <20250128150907.437556-2-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250128150907.437556-1-c.ebner@proxmox.com>

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@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2025-01-28 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 15:09 [pbs-devel] [PATCH proxmox-backup-qemu 1/2] fix: never append archive name extensions twice, use type instead Christian Ebner
2025-01-28 15:09 ` Christian Ebner [this message]
2025-01-28 16:38 ` Markus Frank
2025-01-30 12:43 ` [pbs-devel] applied-series: " Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250128150907.437556-2-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal