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

Unified Diff: lib/src/directory_watcher/mac_os.dart

Issue 861313006: Treat add events for known files as modifications instead of discarding them on Mac OS. Fixes pub s… (Closed) Base URL: https://github.com/dart-lang/watcher.git@master
Patch Set: Created 5 years, 11 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 | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/directory_watcher/mac_os.dart
diff --git a/lib/src/directory_watcher/mac_os.dart b/lib/src/directory_watcher/mac_os.dart
index e3efa2dd64bc034aaeed4b1e9369c67171a036c1..ee2013665f57335cff3a7b6e098d996257bb7062 100644
--- a/lib/src/directory_watcher/mac_os.dart
+++ b/lib/src/directory_watcher/mac_os.dart
@@ -179,12 +179,15 @@ class _MacOSDirectoryWatcher implements ManuallyClosedDirectoryWatcher {
for (var event in events) {
if (event is FileSystemCreateEvent) {
if (!event.isDirectory) {
- // Don't emit ADD events for files or directories that we already
- // know about. Such an event comes from FSEvents reporting an add
- // that happened prior to the watch beginning.
- if (_files.contains(path)) continue;
-
- _emitEvent(ChangeType.ADD, path);
+ // If we already know about the file, treat it like a modification.
nweiz 2015/01/22 00:20:19 "treat it" -> "treat an ADD event"
+ // This can happen if a file is copied on top of an existing one.
+ // We'll see an ADD event for the latter file when from the user's
+ // perspective, the file's contents just changed.
+ var type = _files.contains(path)
+ ? ChangeType.MODIFY
+ : ChangeType.ADD;
+
+ _emitEvent(type, path);
_files.add(path);
continue;
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698