| 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;
|
|
|