From c5c7fd3482e606d12553aa25ff6f75f44273dfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 27 Nov 2024 09:26:04 +0100 Subject: [PATCH] pull-sync: do not interpret older missing snapshots as needs-resync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when loading the verification state for a local snapshot, it must first be ensured that it actually exists, else the lack of manifest will be interpreted as corrupt snapshot triggering a "resync" that is actually a sync of all missing snapshots, not just the newer ones, which is what's actually wanted here. The diff is best seen by telling git to ignore the whitespace changes. Fixes: 0974ddfa ("fix #3786: api: add resync-corrupt option to sync jobs") Signed-off-by: Fabian Grünbichler [ TL: reword subject and add a bit to commit message ] Signed-off-by: Thomas Lamprecht --- src/server/pull.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/server/pull.rs b/src/server/pull.rs index 9abb673a..361ed068 100644 --- a/src/server/pull.rs +++ b/src/server/pull.rs @@ -551,21 +551,23 @@ async fn pull_group( .store .backup_dir(target_ns.clone(), dir.clone()); if let Ok(local_dir) = local_dir { - match local_dir.verify_state() { - Ok(Some(state)) => { - if state == VerifyState::Failed { + if local_dir.full_path().exists() { + match local_dir.verify_state() { + Ok(Some(state)) => { + if state == VerifyState::Failed { + return Some((dir, true)); + } + } + Ok(None) => { + // The verify_state item was not found in the manifest, this means the + // snapshot is new. + } + Err(_) => { + // There was an error loading the manifest, probably better if we + // resync. return Some((dir, true)); } } - Ok(None) => { - // The verify_state item was not found in the manifest, this means the - // snapshot is new. - } - Err(_) => { - // There was an error loading the manifest, probably better if we - // resync. - return Some((dir, true)); - } } } }