Skip to content

Commit

Permalink
ignore not found error on remove operation (#2851)
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj authored May 10, 2022
1 parent a87321e commit a593099
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/storage/utils/filelocks/filelocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package filelocks

import (
"errors"
"io/fs"
"os"
"sync"
"time"
Expand Down Expand Up @@ -140,8 +141,14 @@ func ReleaseLock(lock *flock.Flock) error {

err = lock.Unlock()
if err == nil {
if !lock.Locked() {
if !lock.Locked() && !lock.RLocked() {
err = os.Remove(n)
// there is a concurrency issue when deleting the file
// see https://github.com/owncloud/ocis/issues/3757
// for now we just ignore "not found" errors when they pop up
if err != nil && errors.Is(err, fs.ErrNotExist) {
err = nil
}
}
}
releaseMutexedFlock(n)
Expand Down

0 comments on commit a593099

Please sign in to comment.