Skip unlocking for nil locks

Now that lockRepo receives a context, it is possible that it is canceled
before a lock was created. Thus `unlockRepo` must be able to handle this
case.
This commit is contained in:
Michael Eischer 2020-08-09 13:25:13 +02:00
parent 0c9efa9c2a
commit 2964d2ad15
1 changed files with 4 additions and 0 deletions

View File

@ -86,6 +86,10 @@ func refreshLocks(wg *sync.WaitGroup, done <-chan struct{}) {
}
func unlockRepo(lock *restic.Lock) error {
if lock == nil {
return nil
}
globalLocks.Lock()
defer globalLocks.Unlock()