Commit 81d6ec20 authored by Constantin Konstantinidis's avatar Constantin Konstantinidis Committed by Ian Lance Taylor

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: default avatarIan Lance Taylor <iant@golang.org>
parent 60f34f73
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment