2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

mount: Ignore non-existing locks

Closes #1637
This commit is contained in:
Alexander Neumann 2018-02-25 13:11:03 +01:00
parent 2866f3f31c
commit 7d59df1ab8

View File

@ -91,19 +91,23 @@ func unlockRepo(lock *restic.Lock) error {
globalLocks.Lock()
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 {
debug.Log("error while unlocking: %v", err)
return err
}
for i := 0; i < len(globalLocks.locks); i++ {
if lock == globalLocks.locks[i] {
// remove the lock from the list of locks
globalLocks.locks = append(globalLocks.locks[:i], globalLocks.locks[i+1:]...)
return nil
}
}
debug.Log("unable to find lock %v in the global list of locks, ignoring", lock)
return nil
}
@ -119,6 +123,7 @@ func unlockAll() error {
}
debug.Log("successfully removed lock")
}
globalLocks.locks = globalLocks.locks[:0]
return nil
}