pbs-datastore: add protection info to BackupInfo
and add necessary helper functions (protected_file/is_protected) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
e9558f290a
commit
92c5cf42d1
@ -92,7 +92,9 @@ impl BackupGroup {
|
||||
BackupDir::with_rfc3339(&self.backup_type, &self.backup_id, backup_time)?;
|
||||
let files = list_backup_files(l2_fd, backup_time)?;
|
||||
|
||||
list.push(BackupInfo { backup_dir, files });
|
||||
let protected = backup_dir.is_protected(base_path.to_owned());
|
||||
|
||||
list.push(BackupInfo { backup_dir, files, protected });
|
||||
|
||||
Ok(())
|
||||
},
|
||||
@ -253,6 +255,17 @@ impl BackupDir {
|
||||
relative_path
|
||||
}
|
||||
|
||||
pub fn protected_file(&self, mut path: PathBuf) -> PathBuf {
|
||||
path.push(self.relative_path());
|
||||
path.push(".protected");
|
||||
path
|
||||
}
|
||||
|
||||
pub fn is_protected(&self, base_path: PathBuf) -> bool {
|
||||
let path = self.protected_file(base_path);
|
||||
path.exists()
|
||||
}
|
||||
|
||||
pub fn backup_time_to_string(backup_time: i64) -> Result<String, Error> {
|
||||
// fixme: can this fail? (avoid unwrap)
|
||||
Ok(proxmox_time::epoch_to_rfc3339_utc(backup_time)?)
|
||||
@ -293,6 +306,8 @@ pub struct BackupInfo {
|
||||
pub backup_dir: BackupDir,
|
||||
/// List of data files
|
||||
pub files: Vec<String>,
|
||||
/// Protection Status
|
||||
pub protected: bool,
|
||||
}
|
||||
|
||||
impl BackupInfo {
|
||||
@ -301,8 +316,9 @@ impl BackupInfo {
|
||||
path.push(backup_dir.relative_path());
|
||||
|
||||
let files = list_backup_files(libc::AT_FDCWD, &path)?;
|
||||
let protected = backup_dir.is_protected(base_path.to_owned());
|
||||
|
||||
Ok(BackupInfo { backup_dir, files })
|
||||
Ok(BackupInfo { backup_dir, files, protected })
|
||||
}
|
||||
|
||||
/// Finds the latest backup inside a backup group
|
||||
|
@ -42,7 +42,7 @@ fn create_info(
|
||||
files.push(String::from(MANIFEST_BLOB_NAME));
|
||||
}
|
||||
|
||||
BackupInfo { backup_dir, files }
|
||||
BackupInfo { backup_dir, files, protected: false }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user