Warn when unlock fails instead of returning an error

Only one caller was checking the error.
This commit is contained in:
greatroar 2020-11-28 13:52:47 +01:00 committed by Michael Eischer
parent b2efa0af39
commit dec5008369
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 {