backup: switch over to streaming Iterator improving memory usage

Avoid collecting the whole group list in memory only to iterate and
filter over it again.

Note that the change could result in a indentation change, so best
viewed with `-w` flag.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2022-04-15 12:20:51 +02:00
parent 7b125de3e1
commit 249dde8b63
4 changed files with 55 additions and 64 deletions

View File

@ -537,9 +537,8 @@ pub fn verify_all_backups(
}
};
let mut list = match verify_worker.datastore.list_backup_groups() {
let mut list = match verify_worker.datastore.iter_backup_groups_ok() {
Ok(list) => list
.into_iter()
.filter(|group| !(group.backup_type() == "host" && group.backup_id() == "benchmark"))
.filter(filter_by_owner)
.collect::<Vec<BackupGroup>>(),