mirror of
https://github.com/restic/restic.git
synced 2025-01-02 13:15:16 +00:00
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.
This commit is contained in:
parent
cc90f2ba6b
commit
c6fd13425b
1 changed files with 2 additions and 6 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue