From 2964d2ad158fc3e7d37874e097c19ece0b52eefd Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 9 Aug 2020 13:25:13 +0200 Subject: [PATCH] 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. --- cmd/restic/lock.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/restic/lock.go b/cmd/restic/lock.go index ad5ac6841..b0df2b685 100644 --- a/cmd/restic/lock.go +++ b/cmd/restic/lock.go @@ -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()