Index: lib/src/file_watcher/polling.dart |
diff --git a/lib/src/file_watcher/polling.dart b/lib/src/file_watcher/polling.dart |
index a44f80cdb4654d78277845a8fbbee5de416d9b33..3480ae29eb78094e0b9f86a6d41022cab7039c54 100644 |
--- a/lib/src/file_watcher/polling.dart |
+++ b/lib/src/file_watcher/polling.dart |
@@ -51,7 +51,10 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { |
// We don't mark the file as removed if this is the first poll (indicated by |
// [_lastModified] being null). Instead, below we forward the dart:io error |
// that comes from trying to read the mtime below. |
- if (_lastModified != null && !await new File(path).exists()) { |
+ var pathExists = await new File(path).exists(); |
+ if (_eventsController.isClosed) return; |
+ |
+ if (_lastModified != null && !pathExists) { |
_eventsController.add(new WatchEvent(ChangeType.REMOVE, path)); |
close(); |
return; |
@@ -59,14 +62,17 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { |
var modified; |
try { |
- modified = await getModificationTime(path); |
+ try { |
+ modified = await getModificationTime(path); |
+ } finally { |
Bob Nystrom
2015/07/17 15:58:22
Can you just add this to the outer try?
nweiz
2015/07/17 20:42:18
No, it needs to happen before "_eventsController.a
|
+ if (_eventsController.isClosed) return; |
+ } |
} on FileSystemException catch (error, stackTrace) { |
_eventsController.addError(error, stackTrace); |
close(); |
return; |
} |
- if (_eventsController.isClosed) return; |
if (_lastModified == modified) return; |
if (_lastModified == null) { |