unlock: use proper context for locks cleanup

The list operation used by RemoveStaleLocks or RemoveAllLocks will
already be canceled by the passed in context. Therefore we can also just
cancel the remove operation as the unlock command won't process all lock
files anyways.
This commit is contained in:
Michael Eischer 2020-04-10 11:44:15 +02:00
parent 645a6efaf2
commit 4b0fcaed45
1 changed files with 2 additions and 2 deletions

View File

@ -284,7 +284,7 @@ func RemoveStaleLocks(ctx context.Context, repo Repository) error {
}
if lock.Stale() {
return repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: id.String()})
return repo.Backend().Remove(ctx, Handle{Type: LockFile, Name: id.String()})
}
return nil
@ -294,6 +294,6 @@ func RemoveStaleLocks(ctx context.Context, repo Repository) error {
// RemoveAllLocks removes all locks forcefully.
func RemoveAllLocks(ctx context.Context, repo Repository) error {
return repo.List(ctx, LockFile, func(id ID, size int64) error {
return repo.Backend().Remove(context.TODO(), Handle{Type: LockFile, Name: id.String()})
return repo.Backend().Remove(ctx, Handle{Type: LockFile, Name: id.String()})
})
}