From 57acc769b400ece4c3d48415e6f5c4ab7b6884fa Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 14 Jan 2023 18:14:08 +0100 Subject: [PATCH] lock: Ignore empty lock files These may be left behind by backends which do not guarantee atomic uploads. --- internal/restic/lock.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/restic/lock.go b/internal/restic/lock.go index 94b1801f2..2da3667a3 100644 --- a/internal/restic/lock.go +++ b/internal/restic/lock.go @@ -360,6 +360,12 @@ func ForAllLocks(ctx context.Context, repo Repository, excludeID *ID, fn func(ID if excludeID != nil && id.Equal(*excludeID) { return nil } + if size == 0 { + // Ignore empty lock files as some backends do not guarantee atomic uploads. + // These may leave empty files behind if an upload was interrupted between + // creating the file and writing its data. + return nil + } lock, err := LoadLock(ctx, repo, id) m.Lock()