From c6fd13425b21bba4ee608eb7ec04f9a6b5546390 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Aug 2020 13:36:02 +0200 Subject: [PATCH] remember the refreshed lock file even if removal failed This ensures that restic won't create lots of new lock files without deleting them later on. In some cases a Delete operation on a backend can return a "File does not exist" error even though the Delete operation succeeded. This can for example be caused by request retries. This caused restic to forget about the new lock file and continue trying to remove the old (already deleted) lock file. --- internal/restic/lock.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/restic/lock.go b/internal/restic/lock.go index e79882f80..9a5fd841d 100644 --- a/internal/restic/lock.go +++ b/internal/restic/lock.go @@ -223,15 +223,11 @@ func (l *Lock) Refresh(ctx context.Context) error { return err } - err = l.repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: l.lockID.String()}) - if err != nil { - return err - } - debug.Log("new lock ID %v", id) + oldLockID := l.lockID l.lockID = &id - return nil + return l.repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: oldLockID.String()}) } func (l Lock) String() string {