1
0
mirror of https://github.com/golang/go synced 2024-09-30 14:28:33 -06: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:
Constantin Konstantinidis 2019-10-26 20:01:47 +02:00 committed by Ian Lance Taylor
parent 60f34f739d
commit 81d6ec204f
2 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,7 @@ package os
import ( import (
"io" "io"
"runtime"
"syscall" "syscall"
) )
@ -127,6 +128,13 @@ func removeAll(path string) error {
if err1 == nil || IsNotExist(err1) { if err1 == nil || IsNotExist(err1) {
return nil 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 { if err == nil {
err = err1 err = err1
} }

View File

@ -378,7 +378,7 @@ func TestRemoveAllButReadOnlyAndPathError(t *testing.T) {
func TestRemoveUnreadableDir(t *testing.T) { func TestRemoveUnreadableDir(t *testing.T) {
switch runtime.GOOS { switch runtime.GOOS {
case "js", "windows": case "js":
t.Skipf("skipping test on %s", runtime.GOOS) t.Skipf("skipping test on %s", runtime.GOOS)
} }