Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

[File Watchers] Folder not unwatched when externally renamed #6554

Closed
jasonsanjose opened this issue Jan 16, 2014 · 3 comments
Closed

[File Watchers] Folder not unwatched when externally renamed #6554

jasonsanjose opened this issue Jan 16, 2014 · 3 comments

Comments

@jasonsanjose
Copy link
Member

Discovered this issue in PR #6546 when fixing #6537.

  1. In AppshellFileSystem._enqueueChange insert a conditional breakpoint to log change events: console.log(changedPath),false
  2. Open any project
  3. Add a directory externally in windows explorer, name it foo
  4. In Explorer, rename the directory to bar
  5. In Explorer, paste in any single file into bar
  6. Observe log
C:/Program Files/Brackets/dev/samples/root/Getting Started/
C:/Program Files/Brackets/dev/samples/root/Getting Started/
C:/Program Files/Brackets/dev/samples/root/Getting Started/
C:/Program Files/Brackets/dev/samples/root/Getting Started/
C:/Program Files/Brackets/dev/samples/root/Getting Started/
C:/Program Files/Brackets/dev/samples/root/Getting Started/New folder/
C:/Program Files/Brackets/dev/samples/root/Getting Started/foo/
C:/Program Files/Brackets/dev/samples/root/Getting Started/bar/
C:/Program Files/Brackets/dev/samples/root/Getting Started/bar
C:/Program Files/Brackets/dev/samples/root/Getting Started/New folder/README.md
C:/Program Files/Brackets/dev/samples/root/Getting Started/foo/README.md
C:/Program Files/Brackets/dev/samples/root/Getting Started/foo/README.md
C:/Program Files/Brackets/dev/samples/root/Getting Started/bar/README.md
C:/Program Files/Brackets/dev/samples/root/Getting Started/bar/README.md
C:/Program Files/Brackets/dev/samples/root/Getting Started/New folder/README.md

This issue doesn't manifest in any user visible behavior immediately (it may if you try to recreate a folder reusing one of the older names), but it does leave file watchers in a bad state.

The main problem here is that invalid change events are fired with the old path name, e.g. C:/Program Files/Brackets/dev/samples/root/Getting Started/New folder/README.md. It seems that windows file watchers are smart enough that they stay with a folder even after it's renamed.

The issue is due to the fact that we don't unwatch a folder after a rename. I have a patch for that in a closed PR https://github.com/adobe/brackets/pull/6546/files#diff-0.

@peterflynn also noted that subfolders should also be unwatched and suggested an API change to FileWatcherDomain to add a method for unwatching all paths that start with a prefix.

@jasonsanjose
Copy link
Member Author

Correction, I did find some user facing behavior. After following the above steps...

  1. In Explorer, create another new folder, name it foo (remember that bar presently progressed from New folder->foo->bar)
  2. Paste in any single file into foo
  3. Observe file tree
  4. The file pasted into foo does not appear

A new file watcher was never created for the new foo folder because the FileWatcherDomain hit it's watcher cache and does not add a new watcher for the new foo folder.

@peterflynn
Copy link
Member

FBNC @jasonsanjose via #6565

@jasonsanjose
Copy link
Member Author

Confirmed fixed. Closing.

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

2 participants