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

Unified Diff: packages/watcher/lib/src/directory_watcher/mac_os.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
Index: packages/watcher/lib/src/directory_watcher/mac_os.dart
diff --git a/packages/watcher/lib/src/directory_watcher/mac_os.dart b/packages/watcher/lib/src/directory_watcher/mac_os.dart
index 487225eb4dff495537048fc075216ce92e5d8435..8a17e2e795dd7039f5964d87ade83799a49992d1 100644
--- a/packages/watcher/lib/src/directory_watcher/mac_os.dart
+++ b/packages/watcher/lib/src/directory_watcher/mac_os.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library watcher.directory_watcher.mac_os;
-
import 'dart:async';
import 'dart:io';
@@ -58,7 +56,7 @@ class _MacOSDirectoryWatcher
///
/// This is separate from [_subscriptions] because this stream occasionally
/// needs to be resubscribed in order to work around issue 14849.
- StreamSubscription<FileSystemEvent> _watchSubscription;
+ StreamSubscription<List<FileSystemEvent>> _watchSubscription;
/// The subscription to the [Directory.list] call for the initial listing of
/// the directory to determine its initial state.
@@ -116,9 +114,9 @@ class _MacOSDirectoryWatcher
return;
}
- _sortEvents(batch).forEach((path, events) {
- var canonicalEvent = _canonicalEvent(events);
- events = canonicalEvent == null ?
+ _sortEvents(batch).forEach((path, eventSet) {
+ var canonicalEvent = _canonicalEvent(eventSet);
+ var events = canonicalEvent == null ?
_eventsBasedOnFileSystem(path) : [canonicalEvent];
for (var event in events) {
@@ -139,7 +137,7 @@ class _MacOSDirectoryWatcher
if (_files.containsDir(path)) continue;
- var subscription;
+ StreamSubscription<FileSystemEntity> subscription;
subscription = new Directory(path).list(recursive: true)
.listen((entity) {
if (entity is Directory) return;
@@ -175,7 +173,7 @@ class _MacOSDirectoryWatcher
/// 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>{};
// FSEvents can report past events, including events on the root directory
// such as it being created. We want to ignore these. If the directory is
@@ -187,8 +185,10 @@ class _MacOSDirectoryWatcher
// 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) =>
@@ -294,7 +294,7 @@ class _MacOSDirectoryWatcher
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));
@@ -337,7 +337,7 @@ class _MacOSDirectoryWatcher
// FSEvents can fail to report the contents of the directory being removed
// when the directory itself is removed, so we need to manually mark the
// files as removed.
- 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/linux.dart ('k') | packages/watcher/lib/src/directory_watcher/polling.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698