mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
os: remove read-only directories in RemoveAll on Windows
Remove skipping of TestRemoveUnreadableDir on Windows. Fixes #26295 Change-Id: I364a3caa55406c855ece807759f6298f7e4ddf1e Reviewed-on: https://go-review.googlesource.com/c/go/+/203599 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
60f34f739d
commit
81d6ec204f
@ -8,6 +8,7 @@ package os
|
||||
|
||||
import (
|
||||
"io"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
@ -127,6 +128,13 @@ func removeAll(path string) error {
|
||||
if err1 == nil || IsNotExist(err1) {
|
||||
return nil
|
||||
}
|
||||
if runtime.GOOS == "windows" && IsPermission(err1) {
|
||||
if fs, err := Stat(path); err == nil {
|
||||
if err = Chmod(path, FileMode(0200 | int(fs.Mode()))); err == nil {
|
||||
err1 = Remove(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
err = err1
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ func TestRemoveAllButReadOnlyAndPathError(t *testing.T) {
|
||||
|
||||
func TestRemoveUnreadableDir(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "js", "windows":
|
||||
case "js":
|
||||
t.Skipf("skipping test on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user