Chromium Code Reviews| 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; | 5 library watcher.directory_watcher; |
| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 // Null tells the queue consumer that we're done listing. | 126 // Null tells the queue consumer that we're done listing. |
| 127 _filesToProcess.add(null); | 127 _filesToProcess.add(null); |
| 128 } | 128 } |
| 129 | 129 |
| 130 var stream = new Directory(directory).list(recursive: true); | 130 var stream = new Directory(directory).list(recursive: true); |
| 131 _listSubscription = stream.listen((entity) { | 131 _listSubscription = stream.listen((entity) { |
| 132 assert(_state != _WatchState.UNSUBSCRIBED); | 132 assert(_state != _WatchState.UNSUBSCRIBED); |
| 133 | 133 |
| 134 if (entity is! File) return; | 134 if (entity is! File) return; |
| 135 _filesToProcess.add(entity.path); | 135 _filesToProcess.add(entity.path); |
| 136 }, onError: (error) { | 136 }, onError: (error, [StackTrace stackTrace]) { |
|
Lasse Reichstein Nielsen
2013/10/04 08:45:17
Not optional. Stream is from io-lib.
floitsch
2013/10/05 18:11:48
Done.
| |
| 137 if (!isDirectoryNotFoundException(error)) { | 137 if (!isDirectoryNotFoundException(error)) { |
| 138 // It's some unknown error. Pipe it over to the event stream so the | 138 // It's some unknown error. Pipe it over to the event stream so the |
| 139 // user can see it. | 139 // user can see it. |
| 140 _events.addError(error); | 140 _events.addError(error, stackTrace); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // When an error occurs, we end the listing normally, which has the | 143 // When an error occurs, we end the listing normally, which has the |
| 144 // desired effect of marking all files that were in the directory as | 144 // desired effect of marking all files that were in the directory as |
| 145 // being removed. | 145 // being removed. |
| 146 endListing(); | 146 endListing(); |
| 147 }, onDone: endListing, cancelOnError: true); | 147 }, onDone: endListing, cancelOnError: true); |
| 148 } | 148 } |
| 149 | 149 |
| 150 /// Processes [file] to determine if it has been modified since the last | 150 /// Processes [file] to determine if it has been modified since the last |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 | 272 |
| 273 class _FileStatus { | 273 class _FileStatus { |
| 274 /// The last time the file was modified. | 274 /// The last time the file was modified. |
| 275 DateTime modified; | 275 DateTime modified; |
| 276 | 276 |
| 277 /// The SHA-1 hash of the contents of the file. | 277 /// The SHA-1 hash of the contents of the file. |
| 278 List<int> hash; | 278 List<int> hash; |
| 279 | 279 |
| 280 _FileStatus(this.modified, this.hash); | 280 _FileStatus(this.modified, this.hash); |
| 281 } | 281 } |
| OLD | NEW |