OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library watcher.directory_watcher.polling; | 5 library watcher.directory_watcher.polling; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:crypto/crypto.dart'; | 10 import 'package:crypto/crypto.dart'; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 AsyncQueue<String> _filesToProcess; | 65 AsyncQueue<String> _filesToProcess; |
66 | 66 |
67 /// The set of files that have been seen in the current directory listing. | 67 /// The set of files that have been seen in the current directory listing. |
68 /// | 68 /// |
69 /// Used to tell which files have been removed: files that are in [_statuses] | 69 /// Used to tell which files have been removed: files that are in [_statuses] |
70 /// but not in here when a poll completes have been removed. | 70 /// but not in here when a poll completes have been removed. |
71 final _polledFiles = new Set<String>(); | 71 final _polledFiles = new Set<String>(); |
72 | 72 |
73 _PollingDirectoryWatcher(this.directory, this._pollingDelay) { | 73 _PollingDirectoryWatcher(this.directory, this._pollingDelay) { |
74 _filesToProcess = new AsyncQueue<String>(_processFile, | 74 _filesToProcess = new AsyncQueue<String>(_processFile, |
75 onError: _events.addError); | 75 onError: (e, stackTrace) { |
| 76 if (!_events.isClosed) _events.addError(e, stackTrace); |
| 77 }); |
76 | 78 |
77 _poll(); | 79 _poll(); |
78 } | 80 } |
79 | 81 |
80 void close() { | 82 void close() { |
81 _events.close(); | 83 _events.close(); |
82 | 84 |
83 // If we're in the middle of listing the directory, stop. | 85 // If we're in the middle of listing the directory, stop. |
84 if (_listSubscription != null) _listSubscription.cancel(); | 86 if (_listSubscription != null) _listSubscription.cancel(); |
85 | 87 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 class _FileStatus { | 209 class _FileStatus { |
208 /// The last time the file was modified. | 210 /// The last time the file was modified. |
209 DateTime modified; | 211 DateTime modified; |
210 | 212 |
211 /// The SHA-1 hash of the contents of the file. | 213 /// The SHA-1 hash of the contents of the file. |
212 List<int> hash; | 214 List<int> hash; |
213 | 215 |
214 _FileStatus(this.modified, this.hash); | 216 _FileStatus(this.modified, this.hash); |
215 } | 217 } |
216 | 218 |
OLD | NEW |