Merge pull request #3134 from greatroar/unlock-warn

Warn when unlock fails instead of returning an error
This commit is contained in:
MichaelEischer 2020-12-29 18:30:08 +01:00 committed by GitHub
commit 7fda2f2ad8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 12 deletions

View file

@ -48,12 +48,7 @@ func runCat(gopts GlobalOptions, args []string) error {
return err
}
defer func() {
err := unlockRepo(lock)
if err != nil {
Warnf("unlock repo failed: %v", err)
}
}()
defer unlockRepo(lock)
}
tpe := args[0]

View file

@ -85,9 +85,9 @@ func refreshLocks(wg *sync.WaitGroup, done <-chan struct{}) {
}
}
func unlockRepo(lock *restic.Lock) error {
func unlockRepo(lock *restic.Lock) {
if lock == nil {
return nil
return
}
globalLocks.Lock()
@ -99,18 +99,17 @@ func unlockRepo(lock *restic.Lock) error {
debug.Log("unlocking repository with lock %v", lock)
if err := lock.Unlock(); err != nil {
debug.Log("error while unlocking: %v", err)
return err
Warnf("error while unlocking: %v", err)
return
}
// remove the lock from the list of locks
globalLocks.locks = append(globalLocks.locks[:i], globalLocks.locks[i+1:]...)
return nil
return
}
}
debug.Log("unable to find lock %v in the global list of locks, ignoring", lock)
return nil
}
func unlockAll() error {