Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

fs.watch blocks folder (windows 8) #3963

Closed
ArtemGovorov opened this issue Sep 4, 2012 · 5 comments
Closed

fs.watch blocks folder (windows 8) #3963

ArtemGovorov opened this issue Sep 4, 2012 · 5 comments

Comments

@ArtemGovorov
Copy link

On windows 8 running following code

require('fs').watch('C:/Test');
require('fs').watch('C:/Test/Sub/SubSub');

and trying to rename C:/Test/Sub causes error:

Folder In Use The action can't be completed because the folder or a file in it is open in another program

@bnoordhuis
Copy link
Member

That's a limitation of the Windows file watcher API. Use fs.watchFile() if you don't want that.

@piscisaureus
Copy link

I wish we would be able to work around this, but unfortunately we can't.

@ArtemGovorov
Copy link
Author

System.IO.FileSystemWatcher in .NET uses the same API (ReadDirectoryChangesW) and it works for given scenario. Could you elaborate please why is that impossible?

@piscisaureus
Copy link

ReadDirectoryChangesW (apparently) locks the parent folder of the folder being watched.

You can even replicate this with windows explorer.

  • Create folder c:\a\b
  • Open that folder in windows explorer
  • Try to rename c:\a

System.IO.FileSystemWatcher in .NET uses the same API (ReadDirectoryChangesW) and it works for given scenario.

I don't believe you. Convince me by sharing your test case :-)

@ArtemGovorov
Copy link
Author

Windows explorer actually works fine on Windows 7-8, opened sub-folder explorer just updates the path. Though I can replicate what you're talking about on XP.

Regarding FileSystemWatcher, you're right, I tried to set up some basic test and realised that it does also block parent folder of the folder being watched. Thanks for your time!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants