File tree Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Expand file tree Collapse file tree 3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -1122,7 +1122,7 @@ func removeAll(path string) error {
1122
1122
)
1123
1123
for {
1124
1124
err := os .RemoveAll (path )
1125
- if ! isWindowsAccessDenied (err ) {
1125
+ if ! isWindowsRetryable (err ) {
1126
1126
return err
1127
1127
}
1128
1128
if start .IsZero () {
Original file line number Diff line number Diff line change 6
6
7
7
package testing
8
8
9
- // isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
10
- // which is defined only on Windows .
11
- func isWindowsAccessDenied (err error ) bool {
9
+ // isWindowsRetryable reports whether err is a Windows error code
10
+ // that may be fixed by retrying a failed filesystem operation .
11
+ func isWindowsRetryable (err error ) bool {
12
12
return false
13
13
}
Original file line number Diff line number Diff line change @@ -8,11 +8,25 @@ package testing
8
8
9
9
import (
10
10
"errors"
11
+ "internal/syscall/windows"
11
12
"syscall"
12
13
)
13
14
14
- // isWindowsAccessDenied reports whether err is ERROR_ACCESS_DENIED,
15
- // which is defined only on Windows.
16
- func isWindowsAccessDenied (err error ) bool {
17
- return errors .Is (err , syscall .ERROR_ACCESS_DENIED )
15
+ // isWindowsRetryable reports whether err is a Windows error code
16
+ // that may be fixed by retrying a failed filesystem operation.
17
+ func isWindowsRetryable (err error ) bool {
18
+ for {
19
+ unwrapped := errors .Unwrap (err )
20
+ if unwrapped == nil {
21
+ break
22
+ }
23
+ err = unwrapped
24
+ }
25
+ if err == syscall .ERROR_ACCESS_DENIED {
26
+ return true // Observed in https://go.dev/issue/50051.
27
+ }
28
+ if err == windows .ERROR_SHARING_VIOLATION {
29
+ return true // Observed in https://go.dev/issue/51442.
30
+ }
31
+ return false
18
32
}
You can’t perform that action at this time.
0 commit comments