Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: pkg/watcher/lib/src/directory_watcher/linux.dart

Issue 99483006: Update the Linux watcher to accommodate changes in [Directory.watch]. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/pkg.status ('k') | pkg/watcher/test/directory_watcher/linux_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/watcher/lib/src/directory_watcher/linux.dart
diff --git a/pkg/watcher/lib/src/directory_watcher/linux.dart b/pkg/watcher/lib/src/directory_watcher/linux.dart
index d62c6ef10d42e729c81de68bcd6fc5874d9ebb24..5e86a43444a03ad24a3a0ce4a259de21cc6e9d5c 100644
--- a/pkg/watcher/lib/src/directory_watcher/linux.dart
+++ b/pkg/watcher/lib/src/directory_watcher/linux.dart
@@ -213,7 +213,7 @@ class _LinuxDirectoryWatcher implements ManuallyClosedDirectoryWatcher {
if (oldState == _EntryState.DIRECTORY) {
var watcher = _subWatchers.remove(path);
- if (watcher == null) return;
+ if (watcher == null) continue;
for (var path in watcher._allFiles) {
_eventsController.add(new WatchEvent(ChangeType.REMOVE, path));
}
@@ -247,6 +247,17 @@ class _LinuxDirectoryWatcher implements ManuallyClosedDirectoryWatcher {
/// Handles the underlying event stream closing, indicating that the directory
/// being watched was removed.
void _onDone() {
+ // Most of the time when a directory is removed, its contents will get
+ // individual REMOVE events before the watch stream is closed -- in that
+ // case, [_entries] will be empty here. However, if the directory's removal
+ // is caused by a MOVE, we need to manually emit events.
+ if (isReady) {
+ _entries.forEach((path, state) {
+ if (state == _EntryState.DIRECTORY) return;
+ _eventsController.add(new WatchEvent(ChangeType.REMOVE, path));
+ });
+ }
+
// The parent directory often gets a close event before the subdirectories
// are done emitting events. We wait for them to finish before we close
// [events] so that we can be sure to emit a remove event for every file
« no previous file with comments | « pkg/pkg.status ('k') | pkg/watcher/test/directory_watcher/linux_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698