New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: Remove/RemoveAll should remove read-only folders on Windows #26295

Open
Nnnes opened this Issue Jul 9, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@Nnnes

Nnnes commented Jul 9, 2018

What version of Go are you using (go version)?

go version go1.10.2 windows/amd64

Does this issue reproduce with the latest release?

Untested, but I don't see any changes that would have fixed it

What operating system and processor architecture are you using (go env)?

windows/amd64

What did you do?

package main

import (
	"os"
)

func main() {
	err := os.RemoveAll("./folder_with_icon")
	if err != nil {
		panic(err)
	}
}

folder_with_icon is an empty folder that has had a custom icon added via Windows Explorer's interface (Properties => Customize => Change Icon...).

What did you expect to see?

folder_with_icon should be deleted.

What did you see instead?

panic: remove ./folder_with_icon: Access is denied.

goroutine 1 [running]:
main.main()
        C:/[path]/test.go:10 +0x6a

Notes

This is similar to #9606.

Setting a custom folder icon on Windows sets the read-only attribute on the folder and creates a desktop.ini file with the system attribute inside the folder. Despite being read-only, the folder can be deleted both through File Explorer and by rd /s folder_with_icon by its owner, even if the owner is not an administrator account. The above Go program will not delete the folder, even if it is run with administrator privileges.

os.RemoveAll() removes the desktop.ini but does not delete the folder.

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Jul 9, 2018

By analogy with #9606 it seems that we should do this.

@iamoryanmoshe

This comment has been minimized.

Contributor

iamoryanmoshe commented Jul 20, 2018

I'm working on it

@gopherbot

This comment has been minimized.

gopherbot commented Jul 20, 2018

Change https://golang.org/cl/125261 mentions this issue: os: remove read-only directories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment