lock: Ignore empty lock files

These may be left behind by backends which do not guarantee atomic
uploads.
This commit is contained in:
Michael Eischer 2023-01-14 18:14:08 +01:00
parent 20ad14e362
commit 57acc769b4
1 changed files with 6 additions and 0 deletions

View File

@ -360,6 +360,12 @@ func ForAllLocks(ctx context.Context, repo Repository, excludeID *ID, fn func(ID
if excludeID != nil && id.Equal(*excludeID) {
return nil
}
if size == 0 {
// Ignore empty lock files as some backends do not guarantee atomic uploads.
// These may leave empty files behind if an upload was interrupted between
// creating the file and writing its data.
return nil
}
lock, err := LoadLock(ctx, repo, id)
m.Lock()