mirror of
https://github.com/octoleo/restic.git
synced 2024-11-10 23:31:09 +00:00
Merge pull request #1640 from restic/fix-1637
mount: Ignore non-existing locks
This commit is contained in:
commit
fc1f74d32d
@ -91,19 +91,23 @@ func unlockRepo(lock *restic.Lock) error {
|
|||||||
globalLocks.Lock()
|
globalLocks.Lock()
|
||||||
defer globalLocks.Unlock()
|
defer globalLocks.Unlock()
|
||||||
|
|
||||||
debug.Log("unlocking repository with lock %p", lock)
|
for i := 0; i < len(globalLocks.locks); i++ {
|
||||||
|
if lock == globalLocks.locks[i] {
|
||||||
|
// remove the lock from the repo
|
||||||
|
debug.Log("unlocking repository with lock %v", lock)
|
||||||
if err := lock.Unlock(); err != nil {
|
if err := lock.Unlock(); err != nil {
|
||||||
debug.Log("error while unlocking: %v", err)
|
debug.Log("error while unlocking: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(globalLocks.locks); i++ {
|
// remove the lock from the list of locks
|
||||||
if lock == globalLocks.locks[i] {
|
|
||||||
globalLocks.locks = append(globalLocks.locks[:i], globalLocks.locks[i+1:]...)
|
globalLocks.locks = append(globalLocks.locks[:i], globalLocks.locks[i+1:]...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug.Log("unable to find lock %v in the global list of locks, ignoring", lock)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +123,7 @@ func unlockAll() error {
|
|||||||
}
|
}
|
||||||
debug.Log("successfully removed lock")
|
debug.Log("successfully removed lock")
|
||||||
}
|
}
|
||||||
|
globalLocks.locks = globalLocks.locks[:0]
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user