mirror of
https://github.com/golang/go.git
synced 2025-05-24 08:51:24 +00:00
testing: include ERROR_SHARING_VIOLATION in Windows cleanup retries
Fixes #51442 Updates #50051 Change-Id: I1bfbc08c907077467fd50febbec6299a9b73af41 Reviewed-on: https://go-review.googlesource.com/c/go/+/388916 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
2e9facbdd4
commit
eeb9f095dc
@ -1122,7 +1122,7 @@ func removeAll(path string) error {
|
|||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
err := os.RemoveAll(path)
|
err := os.RemoveAll(path)
|
||||||
if !isWindowsAccessDenied(err) {
|
if !isWindowsRetryable(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if start.IsZero() {
|
if start.IsZero() {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
package testing
|
package testing
|
||||||
|
|
||||||
// isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
|
// isWindowsRetryable reports whether err is a Windows error code
|
||||||
// which is defined only on Windows.
|
// that may be fixed by retrying a failed filesystem operation.
|
||||||
func isWindowsAccessDenied(err error) bool {
|
func isWindowsRetryable(err error) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,25 @@ package testing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"internal/syscall/windows"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
|
// isWindowsRetryable reports whether err is a Windows error code
|
||||||
// which is defined only on Windows.
|
// that may be fixed by retrying a failed filesystem operation.
|
||||||
func isWindowsAccessDenied(err error) bool {
|
func isWindowsRetryable(err error) bool {
|
||||||
return errors.Is(err, syscall.ERROR_ACCESS_DENIED)
|
for {
|
||||||
|
unwrapped := errors.Unwrap(err)
|
||||||
|
if unwrapped == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
err = unwrapped
|
||||||
|
}
|
||||||
|
if err == syscall.ERROR_ACCESS_DENIED {
|
||||||
|
return true // Observed in https://go.dev/issue/50051.
|
||||||
|
}
|
||||||
|
if err == windows.ERROR_SHARING_VIOLATION {
|
||||||
|
return true // Observed in https://go.dev/issue/51442.
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user