Chromium Code Reviews| Index: pkg/watcher/lib/src/directory_watcher.dart |
| diff --git a/pkg/watcher/lib/src/directory_watcher.dart b/pkg/watcher/lib/src/directory_watcher.dart |
| index c5dd9db606bb589bd69fc411a16d428a0de7c6aa..6fa49a9aad0e9a12e1703b7f5f2a45e5bc17d456 100644 |
| --- a/pkg/watcher/lib/src/directory_watcher.dart |
| +++ b/pkg/watcher/lib/src/directory_watcher.dart |
| @@ -118,19 +118,27 @@ class DirectoryWatcher { |
| _filesToProcess.clear(); |
| _polledFiles.clear(); |
| + endListing() { |
| + assert(_state != _WatchState.UNSUBSCRIBED); |
| + _listSubscription = null; |
| + |
| + // Null tells the queue consumer that we're done listing. |
| + _filesToProcess.add(null); |
| + } |
| + |
| var stream = new Directory(directory).list(recursive: true); |
| _listSubscription = stream.listen((entity) { |
| assert(_state != _WatchState.UNSUBSCRIBED); |
| if (entity is! File) return; |
| _filesToProcess.add(entity.path); |
| - }, onDone: () { |
| - assert(_state != _WatchState.UNSUBSCRIBED); |
| - _listSubscription = null; |
| - |
| - // Null tells the queue consumer that we're done listing. |
| - _filesToProcess.add(null); |
| - }); |
| + }, onError: (error) { |
| + // If an error occurred during the listing, it usually means the |
|
nweiz
2013/08/14 19:43:11
Check if the error is the error we expect from the
Bob Nystrom
2013/08/16 21:40:19
Done. Instead of printing it, I pipe the error to
|
| + // directory doesn't exist. We end the listing normally, which has the |
| + // desired effect of marking all files that were in the directory as |
| + // being removed. |
| + endListing(); |
| + }, onDone: endListing); |
| } |
| /// Processes [file] to determine if it has been modified since the last |