shama / gaze

:crystal_ball: A globbing fs.watch wrapper built from the best parts of other fine watch libs.
MIT License
1.16k stars 167 forks source link

Deep folders can not be renamed while Gaze is watching #249

Open kireerik opened 6 years ago

kireerik commented 6 years ago

Minimal directory structure:

shama commented 6 years ago

I can rename folders while gaze is watching.

kireerik commented 6 years ago

Can you do it under Windows?

shama commented 6 years ago

@kireerik We could probably save a lot of time if you post repro steps and more information about your environment and issue you are running into.

kireerik commented 6 years ago

This is the minimal code where the issue is reproducible:

const {Gaze} = require('gaze')

new Gaze('watchedDirectory' + '/**')

If I try to edit a folder name within a watched folder for example using Windows' file manager then I am getting an error prompt like this:

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

So it can not be renamed while Gaze is watching.

shama commented 6 years ago

Windows version? Node.js version? Are you watching files from a vagrant things or shared folder or dropbox, etc

Also gaze watches file patterns, so instead of doing new Gaze('watchedDirectory' + '/**'), the 'watchedDirectory' probably isnt a file pattern. So do new Gaze('**', { cwd: 'watcheDir' }) instead.

kireerik commented 6 years ago

Windows 10 Pro 1083 Node.js 10.4.0 No it is a simple folder.

I see. new Gaze('**', { cwd: 'watcheDir' }) doesn't makes any difference.

shama commented 6 years ago

Nothing else running that could be holding those files?

FWIW, we have tests that rename files gaze is watching that passes on Windows and this is the first Ive heard of this issue.

kireerik commented 6 years ago

No, nothing else. As soon as I stop Gaze I can rename a folder.

As I can see the linked test is for renaming a file and not a folder.

I think Gaze is probably watching all files through watching the sub folders recursively or something like that. I can't modify the watched folder's name either, which makes sense and it seems to me that the sub folders are working just the same way.

kireerik commented 6 years ago

Renaming an empty folder works mostly, but for the 2. renaming I get the following error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, watch 'site\folder\'
    at FSWatcher.start (fs.js:1409:26)
    at Object.fs.watch (fs.js:1446:11)
    at Gaze._watchDir (node_modules\gaze\lib\gaze.js:314:30)
    at node_modules\gaze\lib\gaze.js:387:10
    at iterate (node_modules\gaze\lib\helper.js:69:5)
    at node_modules\gaze\lib\helper.js:78:11
    at node_modules\gaze\lib\gaze.js:452:5
    at iterate (node_modules\gaze\lib\helper.js:69:5)
    at node_modules\gaze\lib\helper.js:78:11
    at node_modules\gaze\lib\gaze.js:452:5
Emitted 'error' event at:
    at Gaze.emit (node_modules\gaze\lib\gaze.js:102:32)
    at Gaze._handleError (node_modules\gaze\lib\gaze.js:468:15)
    at Gaze._watchDir (node_modules\gaze\lib\gaze.js:331:17)
    at node_modules\gaze\lib\gaze.js:387:10
    [... lines matching original stack trace ...]
    at node_modules\gaze\lib\gaze.js:452:5
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

folderCurrent was renamed to folder which was renamed to folderNext. Watched directory is site.

A non empty folder gives the above error as well, but right away with the 1. renaming.

Adding an empty folder within the folder makes no difference, but once I add a file to the newly added folder the initially described issue occurs with the error prompt and the folder name can not be modified.

kireerik commented 6 years ago

I think we should keep this issue opened, since it is well defined by now and it is also consistently reproducible.

shama commented 6 years ago

Sure I'll reopen and assign to you. I cannot repro.

kireerik commented 6 years ago

All right, thank you!

May I ask you on which system can you not reproduce this?

(This might helps you to reproduce, if it is an issue on your system as well: https://github.com/shama/gaze/issues/249#issue-331191188)

wll8 commented 1 year ago