From 87be232d1c771200617329ed4cc3c09cf21bc730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 13 May 2022 11:33:08 +0200 Subject: [PATCH] pull/sync: clamp (local) max-depth if unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to handle the unlikely case of `ns` being deeper than `remote-ns`, `max-depth` being set to `None` and a too-deep sub-ns of `ns` existing. such a sub-ns cannot have been created by a previous run of this sync job, so avoid unexpectedly removing it. Signed-off-by: Fabian Grünbichler --- src/server/pull.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/server/pull.rs b/src/server/pull.rs index 65d25318..0ec8999c 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -17,8 +17,8 @@ use proxmox_sys::task_log; use pbs_api_types::{ Authid, BackupNamespace, DatastoreWithNamespace, GroupFilter, GroupListItem, NamespaceListItem, - Operation, RateLimitConfig, Remote, SnapshotListItem, PRIV_DATASTORE_AUDIT, - PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, + Operation, RateLimitConfig, Remote, SnapshotListItem, MAX_NAMESPACE_DEPTH, + PRIV_DATASTORE_AUDIT, PRIV_DATASTORE_BACKUP, PRIV_DATASTORE_MODIFY, }; use pbs_client::{ @@ -875,9 +875,14 @@ fn check_and_remove_vanished_ns( let mut errors = false; let user_info = CachedUserInfo::new()?; + // clamp like remote does so that we don't list more than we can ever have synced. + let max_depth = params + .max_depth + .unwrap_or_else(|| MAX_NAMESPACE_DEPTH - params.remote_ns.depth()); + let mut local_ns_list: Vec = params .store - .recursive_iter_backup_ns_ok(params.ns.clone(), params.max_depth)? + .recursive_iter_backup_ns_ok(params.ns.clone(), Some(max_depth))? .filter(|ns| { let store_with_ns = params.store_with_ns(ns.clone()); let user_privs = user_info.lookup_privs(¶ms.owner, &store_with_ns.acl_path());