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

Cannot rename/move parent folder of watched folder #356

Closed
huynn96 opened this issue Dec 30, 2020 · 6 comments
Closed

Cannot rename/move parent folder of watched folder #356

huynn96 opened this issue Dec 30, 2020 · 6 comments
Labels
need-feedback Requires feedback to be actionable windows

Comments

@huynn96
Copy link

huynn96 commented Dec 30, 2020

Before reporting an issue, please ensure you are using the latest release of fsnotify.

Which operating system (GOOS) and version are you using?

OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17134 N/A Build 17134
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free

Please describe the issue that occurred.

I watched path: C:\test1\test2
But when i rename or move folder C:\test1 it show error message "The action can't be completed because the folder or a file in it is open in another program"

Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.

`func TestMonitorFolder(t *testing.T) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()

done := make(chan bool)
go func() {
	for {
		select {
		case event, ok := <-watcher.Events:
			if !ok {
				return
			}
			log.Println("event:", event)
			if event.Op&fsnotify.Write == fsnotify.Write {
				log.Println("modified file:", event.Name)
			}
		case err, ok := <-watcher.Errors:
			if !ok {
				return
			}
			log.Println("error:", err)
		}
	}
}()

err = watcher.Add("C:\\test1\\test2")
if err != nil {
	log.Fatal(err)
}
<-done

}`

@cyf-gh
Copy link

cyf-gh commented Jan 15, 2021

I have the same problem. Is there any solution?

@Vallasc
Copy link

Vallasc commented Aug 8, 2021

Same problem here!

@arp242
Copy link
Member

arp242 commented Jul 31, 2022

I can move the watched directory itself (events even keep working), but not the parent directory.

For example, if I run:

C:\Users\martin\fsnotify> go run ./cmd/fsnotify test1/test2

Then openfiles shows the following locks:

C:\Users\martin\fsnotify> openfiles | findstr test1
364   fsnotify.exe         C:\Users\martin\fsnotify\test1\test2

And moving the directory indeed fails:

C:\Users\martin\fsnotify> move test1 xxx
Access is denied.

I think this is just how Windows works; I see other people saying the same (e.g. here), and I've run in to problems with this over the years.

Maybe @mattn has any idea about this?

@arp242 arp242 added the need-feedback Requires feedback to be actionable label Jul 31, 2022
@arp242
Copy link
Member

arp242 commented Aug 6, 2022

I think #370 may have fixed this. I'll close this for now as I can't reproduce it, but feel free to get back and we can reopen.

@arp242 arp242 closed this as completed Aug 6, 2022
@Eznopot
Copy link

Eznopot commented Apr 3, 2024

Hello,
I've just come across this issue and I don't think it's fixed. I'm working on a project where I'm watching a user's entire file system on Windows. Everything seems to work normally but I can't delete/move/rename a folder. Currently my watcher only watches folders as recommended in the documentation. Do you have an idea for a fix?

@arp242
Copy link
Member

arp242 commented Apr 3, 2024

You need to create a new issue with full details and a way to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-feedback Requires feedback to be actionable windows
Projects
None yet
Development

No branches or pull requests

6 participants