Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: packages/watcher/lib/src/directory_watcher/windows.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/watcher/lib/src/directory_watcher/polling.dart ('k') | packages/watcher/lib/src/file_watcher.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/watcher/lib/src/directory_watcher/windows.dart
diff --git a/packages/watcher/lib/src/directory_watcher/windows.dart b/packages/watcher/lib/src/directory_watcher/windows.dart
index 08995196444599a3dfe84fa13de0e26080a42a45..67a274198e8000b5cab441cb4d03626d34bbdafe 100644
--- a/packages/watcher/lib/src/directory_watcher/windows.dart
+++ b/packages/watcher/lib/src/directory_watcher/windows.dart
@@ -3,8 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
// TODO(rnystrom): Merge with mac_os version.
-library watcher.directory_watcher.windows;
-
import 'dart:async';
import 'dart:collection';
import 'dart:io';
@@ -136,7 +134,7 @@ class _WindowsDirectoryWatcher
event is FileSystemDeleteEvent ||
(FileSystemEntity.typeSync(path) ==
FileSystemEntityType.NOT_FOUND)) {
- for (var path in _files.toSet()) {
+ for (var path in _files.paths) {
_emitEvent(ChangeType.REMOVE, path);
}
_files.clear();
@@ -163,10 +161,10 @@ class _WindowsDirectoryWatcher
/// The callback that's run when [Directory.watch] emits a batch of events.
void _onBatch(List<FileSystemEvent> batch) {
- _sortEvents(batch).forEach((path, events) {
+ _sortEvents(batch).forEach((path, eventSet) {
- var canonicalEvent = _canonicalEvent(events);
- events = canonicalEvent == null ?
+ var canonicalEvent = _canonicalEvent(eventSet);
+ var events = canonicalEvent == null ?
_eventsBasedOnFileSystem(path) : [canonicalEvent];
for (var event in events) {
@@ -182,20 +180,20 @@ class _WindowsDirectoryWatcher
if (_files.containsDir(path)) continue;
var stream = new Directory(path).list(recursive: true);
- var sub;
- sub = stream.listen((entity) {
+ StreamSubscription<FileSystemEntity> subscription;
+ subscription = stream.listen((entity) {
if (entity is Directory) return;
if (_files.contains(path)) return;
_emitEvent(ChangeType.ADD, entity.path);
_files.add(entity.path);
}, onDone: () {
- _listSubscriptions.remove(sub);
+ _listSubscriptions.remove(subscription);
}, onError: (e, stackTrace) {
- _listSubscriptions.remove(sub);
+ _listSubscriptions.remove(subscription);
_emitError(e, stackTrace);
}, cancelOnError: true);
- _listSubscriptions.add(sub);
+ _listSubscriptions.add(subscription);
} else if (event is FileSystemModifyEvent) {
if (!event.isDirectory) {
_emitEvent(ChangeType.MODIFY, path);
@@ -219,15 +217,17 @@ class _WindowsDirectoryWatcher
/// The returned events won't contain any [FileSystemMoveEvent]s, nor will it
/// contain any events relating to [path].
Map<String, Set<FileSystemEvent>> _sortEvents(List<FileSystemEvent> batch) {
- var eventsForPaths = {};
+ var eventsForPaths = <String, Set>{};
// Events within directories that already have events are superfluous; the
// directory's full contents will be examined anyway, so we ignore such
// events. Emitting them could cause useless or out-of-order events.
var directories = unionAll(batch.map((event) {
if (!event.isDirectory) return new Set();
- if (event is! FileSystemMoveEvent) return new Set.from([event.path]);
- return new Set.from([event.path, event.destination]);
+ if (event is FileSystemMoveEvent) {
+ return new Set.from([event.path, event.destination]);
+ }
+ return new Set.from([event.path]);
}));
isInModifiedDirectory(path) =>
@@ -322,7 +322,7 @@ class _WindowsDirectoryWatcher
var fileExists = new File(path).existsSync();
var dirExists = new Directory(path).existsSync();
- var events = [];
+ var events = <FileSystemEvent>[];
if (fileExisted) {
if (fileExists) {
events.add(new ConstructableFileSystemModifyEvent(path, false, false));
@@ -357,7 +357,7 @@ class _WindowsDirectoryWatcher
_watchSubscription = null;
// Emit remove events for any remaining files.
- for (var file in _files.toSet()) {
+ for (var file in _files.paths) {
_emitEvent(ChangeType.REMOVE, file);
}
_files.clear();
« no previous file with comments | « packages/watcher/lib/src/directory_watcher/polling.dart ('k') | packages/watcher/lib/src/file_watcher.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698