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:
@ -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)? {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user