datastore status: do not count empty groups

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2022-01-07 08:40:22 +01:00
parent ba857cbe68
commit b44483a853
1 changed files with 12 additions and 8 deletions

View File

@ -568,6 +568,9 @@ fn get_snapshots_count(store: &DataStore, filter_owner: Option<&Authid>) -> Resu
.try_fold(Counts::default(), |mut counts, group| {
let snapshot_count = group.list_backups(&base_path)?.len() as u64;
// only include groups with snapshots (avoid confusing users
// by counting/displaying emtpy groups)
if snapshot_count > 0 {
let type_count = match group.backup_type() {
"ct" => counts.ct.get_or_insert(Default::default()),
"vm" => counts.vm.get_or_insert(Default::default()),
@ -577,6 +580,7 @@ fn get_snapshots_count(store: &DataStore, filter_owner: Option<&Authid>) -> Resu
type_count.groups += 1;
type_count.snapshots += snapshot_count;
}
Ok(counts)
})