datastore: move last_backup from BackupInfo to BackupGroup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
@ -103,6 +103,19 @@ impl BackupGroup {
|
||||
Ok(list)
|
||||
}
|
||||
|
||||
/// Finds the latest backup inside a backup group
|
||||
pub fn last_backup(
|
||||
&self,
|
||||
base_path: &Path,
|
||||
only_finished: bool,
|
||||
) -> Result<Option<BackupInfo>, Error> {
|
||||
let backups = self.list_backups(base_path)?;
|
||||
Ok(backups
|
||||
.into_iter()
|
||||
.filter(|item| !only_finished || item.is_finished())
|
||||
.max_by_key(|item| item.backup_dir.backup_time()))
|
||||
}
|
||||
|
||||
pub fn last_successful_backup(&self, base_path: &Path) -> Result<Option<i64>, Error> {
|
||||
let mut last = None;
|
||||
|
||||
@ -363,19 +376,6 @@ impl BackupInfo {
|
||||
})
|
||||
}
|
||||
|
||||
/// Finds the latest backup inside a backup group
|
||||
pub fn last_backup(
|
||||
base_path: &Path,
|
||||
group: &BackupGroup,
|
||||
only_finished: bool,
|
||||
) -> Result<Option<BackupInfo>, Error> {
|
||||
let backups = group.list_backups(base_path)?;
|
||||
Ok(backups
|
||||
.into_iter()
|
||||
.filter(|item| !only_finished || item.is_finished())
|
||||
.max_by_key(|item| item.backup_dir.backup_time()))
|
||||
}
|
||||
|
||||
pub fn sort_list(list: &mut Vec<BackupInfo>, ascendending: bool) {
|
||||
if ascendending {
|
||||
// oldest first
|
||||
|
Reference in New Issue
Block a user