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

Unified Diff: runtime/bin/file_patch.dart

Issue 39613002: Close file watcher when target is deleted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't always emit delete, and fix docs. Created 7 years, 2 months 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 | « no previous file | runtime/bin/file_system_watcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_patch.dart
diff --git a/runtime/bin/file_patch.dart b/runtime/bin/file_patch.dart
index 93367f4d9d7098d50c39064ebed40251adf011a1..a08eaf99b64acc270937220047dbb834678f1fee 100644
--- a/runtime/bin/file_patch.dart
+++ b/runtime/bin/file_patch.dart
@@ -76,6 +76,7 @@ class _FileSystemWatcherImpl
}
var socket = new _RawSocket(new _NativeSocket.watch(socketId));
_subscription = socket.expand((event) {
+ bool stop = false;
var events = [];
var pair = {};
if (event == RawSocketEvent.READ) {
@@ -87,18 +88,22 @@ class _FileSystemWatcherImpl
}
return path;
}
+ void add(event) {
+ if ((event.type & _events) == 0) return;
+ events.add(event);
+ }
while (socket.available() > 0) {
for (var event in _readEvents()) {
if (event == null) continue;
var path = getPath(event);
if ((event[0] & FileSystemEvent.CREATE) != 0) {
- events.add(new FileSystemCreateEvent._(path));
+ add(new FileSystemCreateEvent._(path));
}
if ((event[0] & FileSystemEvent.MODIFY) != 0) {
- events.add(new FileSystemModifyEvent._(path, true));
+ add(new FileSystemModifyEvent._(path, true));
}
if ((event[0] & FileSystemEvent._MODIFY_ATTRIBUTES) != 0) {
- events.add(new FileSystemModifyEvent._(path, false));
+ add(new FileSystemModifyEvent._(path, false));
}
if ((event[0] & FileSystemEvent.MOVE) != 0) {
int link = event[1];
@@ -111,11 +116,15 @@ class _FileSystemWatcherImpl
pair[link] = event;
}
} else {
- events.add(new FileSystemMoveEvent._(path, null));
+ add(new FileSystemMoveEvent._(path, null));
}
}
if ((event[0] & FileSystemEvent.DELETE) != 0) {
- events.add(new FileSystemDeleteEvent._(path));
+ add(new FileSystemDeleteEvent._(path));
+ }
+ if ((event[0] & FileSystemEvent._DELETE_SELF) != 0) {
+ add(new FileSystemDeleteEvent._(path));
+ stop = true;
}
}
}
@@ -127,9 +136,9 @@ class _FileSystemWatcherImpl
} else {
assert(false);
}
+ if (stop) socket.close();
return events;
})
- .where((event) => (event.type & _events) != 0)
.listen(_controller.add, onDone: _cancel);
}
@@ -138,6 +147,7 @@ class _FileSystemWatcherImpl
if (_subscription != null) {
_subscription.cancel();
}
+ _controller.close();
}
Stream<FileSystemEvent> get stream => _controller.stream;
« no previous file with comments | « no previous file | runtime/bin/file_system_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698