diff options
author | zeripath <art27@cantab.net> | 2021-07-20 18:23:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 20:23:01 +0300 |
commit | 97381aad5df7e6a4b65d9097b6b89b4e9b692528 (patch) | |
tree | b5862e13e8a855db93bd63ceef453d9a13fa9f04 /modules/util | |
parent | b26c3b482feb57704aa399d8d72a959ce667b879 (diff) | |
download | gitea-97381aad5df7e6a4b65d9097b6b89b4e9b692528.tar.gz gitea-97381aad5df7e6a4b65d9097b6b89b4e9b692528.zip |
Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479)
Fix #16427 (again!)
* handle sharing violation error code
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/util')
-rw-r--r-- | modules/util/remove.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/util/remove.go b/modules/util/remove.go index 754f3b7c11..d05ee9fe4a 100644 --- a/modules/util/remove.go +++ b/modules/util/remove.go @@ -6,10 +6,13 @@ package util import ( "os" + "runtime" "syscall" "time" ) +const windowsSharingViolationError syscall.Errno = 32 + // Remove removes the named file or (empty) directory with at most 5 attempts. func Remove(name string) error { var err error @@ -25,6 +28,12 @@ func Remove(name string) error { continue } + if unwrapped == windowsSharingViolationError && runtime.GOOS == "windows" { + // try again + <-time.After(100 * time.Millisecond) + continue + } + if unwrapped == syscall.ENOENT { // it's already gone return nil @@ -48,6 +57,12 @@ func RemoveAll(name string) error { continue } + if unwrapped == windowsSharingViolationError && runtime.GOOS == "windows" { + // try again + <-time.After(100 * time.Millisecond) + continue + } + if unwrapped == syscall.ENOENT { // it's already gone return nil @@ -71,6 +86,12 @@ func Rename(oldpath, newpath string) error { continue } + if unwrapped == windowsSharingViolationError && runtime.GOOS == "windows" { + // try again + <-time.After(100 * time.Millisecond) + continue + } + if i == 0 && os.IsNotExist(err) { return err } |