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

@ -42,7 +42,8 @@ pub fn prune_datastore(
let privs = user_info.lookup_privs(&auth_id, &["datastore", store]);
let has_privs = privs & PRIV_DATASTORE_MODIFY != 0;
for group in datastore.list_backup_groups()? {
for group in datastore.iter_backup_groups()? {
let group = group?;
let list = group.list_backups(&datastore.base_path())?;
if !has_privs && !datastore.owns_backup(&group, &auth_id)? {

View File

@ -797,7 +797,8 @@ pub async fn pull_store(
if params.remove_vanished {
let result: Result<(), Error> = proxmox_lang::try_block!({
for local_group in params.store.list_backup_groups()? {
for local_group in params.store.iter_backup_groups()? {
let local_group = local_group?;
if new_groups.contains(&local_group) {
continue;
}