remove BackupGroup::list_groups

BackupInfo::list_backup_groups is identical code-wise, and makes more
sense as entry point for listing groups.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-11-30 16:27:18 +01:00 committed by Dietmar Maurer
parent 844660036b
commit 7f3b0f67e7
4 changed files with 4 additions and 18 deletions

View File

@ -145,20 +145,6 @@ impl BackupGroup {
Ok(last) Ok(last)
} }
pub fn list_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
let mut list = Vec::new();
tools::scandir(libc::AT_FDCWD, base_path, &BACKUP_TYPE_REGEX, |l0_fd, backup_type, file_type| {
if file_type != nix::dir::Type::Directory { return Ok(()); }
tools::scandir(l0_fd, backup_type, &BACKUP_ID_REGEX, |_l1_fd, backup_id, file_type| {
if file_type != nix::dir::Type::Directory { return Ok(()); }
list.push(BackupGroup::new(backup_type, backup_id));
Ok(())
})
})?;
Ok(list)
}
} }
impl std::fmt::Display for BackupGroup { impl std::fmt::Display for BackupGroup {

View File

@ -533,7 +533,7 @@ pub fn verify_all_backups(
} }
}; };
let mut list = match BackupGroup::list_groups(&datastore.base_path()) { let mut list = match BackupInfo::list_backup_groups(&datastore.base_path()) {
Ok(list) => list Ok(list) => list
.into_iter() .into_iter()
.filter(|group| !(group.backup_type() == "host" && group.backup_id() == "benchmark")) .filter(|group| !(group.backup_type() == "host" && group.backup_id() == "benchmark"))

View File

@ -565,7 +565,7 @@ pub async fn pull_store(
if delete { if delete {
let result: Result<(), Error> = proxmox::try_block!({ let result: Result<(), Error> = proxmox::try_block!({
let local_groups = BackupGroup::list_groups(&tgt_store.base_path())?; let local_groups = BackupInfo::list_backup_groups(&tgt_store.base_path())?;
for local_group in local_groups { for local_group in local_groups {
if new_groups.contains(&local_group) { continue; } if new_groups.contains(&local_group) { continue; }
worker.log(format!("delete vanished group '{}/{}'", local_group.backup_type(), local_group.backup_id())); worker.log(format!("delete vanished group '{}/{}'", local_group.backup_type(), local_group.backup_id()));

View File

@ -4,7 +4,7 @@ use proxmox::try_block;
use crate::{ use crate::{
api2::types::*, api2::types::*,
backup::{compute_prune_info, BackupGroup, DataStore, PruneOptions}, backup::{compute_prune_info, BackupInfo, DataStore, PruneOptions},
server::jobstate::Job, server::jobstate::Job,
server::WorkerTask, server::WorkerTask,
task_log, task_log,
@ -43,7 +43,7 @@ pub fn do_prune_job(
let base_path = datastore.base_path(); let base_path = datastore.base_path();
let groups = BackupGroup::list_groups(&base_path)?; let groups = BackupInfo::list_backup_groups(&base_path)?;
for group in groups { for group in groups {
let list = group.list_backups(&base_path)?; let list = group.list_backups(&base_path)?;
let mut prune_info = compute_prune_info(list, &prune_options)?; let mut prune_info = compute_prune_info(list, &prune_options)?;