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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.mac_os; 5 library watcher.directory_watcher.mac_os;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if (MacOSDirectoryWatcher.logDebugInfo) { 172 if (MacOSDirectoryWatcher.logDebugInfo) {
173 print("[$_id] canonical event for $relativePath: " 173 print("[$_id] canonical event for $relativePath: "
174 "${_formatEvent(canonicalEvent)}"); 174 "${_formatEvent(canonicalEvent)}");
175 print("[$_id] actionable events for $relativePath: " 175 print("[$_id] actionable events for $relativePath: "
176 "${events.map(_formatEvent)}"); 176 "${events.map(_formatEvent)}");
177 } 177 }
178 178
179 for (var event in events) { 179 for (var event in events) {
180 if (event is FileSystemCreateEvent) { 180 if (event is FileSystemCreateEvent) {
181 if (!event.isDirectory) { 181 if (!event.isDirectory) {
182 // Don't emit ADD events for files or directories that we already 182 // 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"
183 // know about. Such an event comes from FSEvents reporting an add 183 // This can happen if a file is copied on top of an existing one.
184 // that happened prior to the watch beginning. 184 // We'll see an ADD event for the latter file when from the user's
185 if (_files.contains(path)) continue; 185 // perspective, the file's contents just changed.
186 var type = _files.contains(path)
187 ? ChangeType.MODIFY
188 : ChangeType.ADD;
186 189
187 _emitEvent(ChangeType.ADD, path); 190 _emitEvent(type, path);
188 _files.add(path); 191 _files.add(path);
189 continue; 192 continue;
190 } 193 }
191 194
192 if (_files.containsDir(path)) continue; 195 if (_files.containsDir(path)) continue;
193 196
194 var stream = Chain.track(new Directory(path).list(recursive: true)); 197 var stream = Chain.track(new Directory(path).list(recursive: true));
195 _listSubscription = stream.listen((entity) { 198 _listSubscription = stream.listen((entity) {
196 if (entity is Directory) return; 199 if (entity is Directory) return;
197 if (_files.contains(path)) return; 200 if (_files.contains(path)) return;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 } else if (event is FileSystemDeleteEvent) { 491 } else if (event is FileSystemDeleteEvent) {
489 return "delete $type $path"; 492 return "delete $type $path";
490 } else if (event is FileSystemModifyEvent) { 493 } else if (event is FileSystemModifyEvent) {
491 return "modify $type $path"; 494 return "modify $type $path";
492 } else if (event is FileSystemMoveEvent) { 495 } else if (event is FileSystemMoveEvent) {
493 return "move $type $path to " 496 return "move $type $path to "
494 "${p.relative(event.destination, from: directory)}"; 497 "${p.relative(event.destination, from: directory)}";
495 } 498 }
496 } 499 }
497 } 500 }
OLDNEW
« 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