[pbs-devel] [PATCH v3 proxmox-backup 05/20] datastore: add helpers to check if snapshot/group is trash

Christian Ebner c.ebner at proxmox.com
Tue May 13 15:52:32 CEST 2025


The convenience helper method check for the trash marker file being
present within the snapshot/group directory. From the absence of the
marker file it may not be inferred that the snapshot/group is present
as regular item however.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
 pbs-datastore/src/backup_info.rs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs
index 9ce4cb0f8..ec6d97790 100644
--- a/pbs-datastore/src/backup_info.rs
+++ b/pbs-datastore/src/backup_info.rs
@@ -99,6 +99,13 @@ impl BackupGroup {
         self.full_group_path().exists()
     }
 
+    /// Check if the group is currently marked as trash by checking the presence of the trash
+    /// marker file in the group's directory
+    pub fn is_trash(&self) -> bool {
+        let path = self.full_group_path().join(TRASH_MARKER_FILENAME);
+        path.exists()
+    }
+
     pub fn list_backups(&self) -> Result<Vec<BackupInfo>, Error> {
         let mut list = vec![];
 
@@ -480,6 +487,13 @@ impl BackupDir {
         path.exists()
     }
 
+    /// Check if the snapshot is currently marked as trash by checking the presence of the trash
+    /// marker file in the snapshot's directory
+    pub fn is_trash(&self) -> bool {
+        let path = self.full_path().join(TRASH_MARKER_FILENAME);
+        path.exists()
+    }
+
     pub fn backup_time_to_string(backup_time: i64) -> Result<String, Error> {
         // fixme: can this fail? (avoid unwrap)
         proxmox_time::epoch_to_rfc3339_utc(backup_time)
-- 
2.39.5





More information about the pbs-devel mailing list