Skip to content
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

Closed
Nnnes opened this issue Jul 9, 2018 · 4 comments
Closed

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

Nnnes opened this issue Jul 9, 2018 · 4 comments

Comments

@Nnnes
Copy link

@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.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 9, 2018

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

@iamoryanmoshe

This comment has been minimized.

Copy link
Contributor

@iamoryanmoshe iamoryanmoshe commented Jul 20, 2018

I'm working on it

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 20, 2018

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

@ianlancetaylor ianlancetaylor modified the milestones: Go1.12, Go1.13 Dec 20, 2018
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@smasher164 smasher164 modified the milestones: Backlog, Go1.14 Oct 11, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 26, 2019

Change https://golang.org/cl/203599 mentions this issue: os: Remove/RemoveAll removes read-only folders on Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.