Remove debug prints.
As far as I know, the issue that required these was fixed a while ago.
R=rnystrom@google.com
Review URL: https://codereview.chromium.org//1187553003.
diff --git a/lib/src/directory_watcher/mac_os.dart b/lib/src/directory_watcher/mac_os.dart
index c242c75..89ac905 100644
--- a/lib/src/directory_watcher/mac_os.dart
+++ b/lib/src/directory_watcher/mac_os.dart
@@ -7,7 +7,6 @@
import 'dart:async';
import 'dart:io';
-import 'package:path/path.dart' as p;
import 'package:stack_trace/stack_trace.dart';
import '../constructable_file_system_event.dart';
@@ -27,19 +26,11 @@
/// This also works around issues 16003 and 14849 in the implementation of
/// [Directory.watch].
class MacOSDirectoryWatcher extends ResubscribableDirectoryWatcher {
- // TODO(nweiz): remove these when issue 15042 is fixed.
- static var logDebugInfo = false;
- static var _count = 0;
-
MacOSDirectoryWatcher(String directory)
- : super(directory, () => new _MacOSDirectoryWatcher(directory, _count++));
+ : super(directory, () => new _MacOSDirectoryWatcher(directory));
}
class _MacOSDirectoryWatcher implements ManuallyClosedDirectoryWatcher {
- // TODO(nweiz): remove these when issue 15042 is fixed.
- static var _count = 0;
- final String _id;
-
final String directory;
Stream<WatchEvent> get events => _eventsController.stream;
@@ -77,10 +68,9 @@
/// events (see issue 14373).
Timer _bogusEventTimer;
- _MacOSDirectoryWatcher(String directory, int parentId)
+ _MacOSDirectoryWatcher(String directory)
: directory = directory,
- _files = new PathSet(directory),
- _id = "$parentId/${_count++}" {
+ _files = new PathSet(directory) {
_startWatch();
// Before we're ready to emit events, wait for [_listDir] to complete and
@@ -90,27 +80,12 @@
// If we do receive a batch of events, [_onBatch] will ensure that these
// futures don't fire and that the directory is re-listed.
Future.wait([
- _listDir().then((_) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] finished initial directory list");
- }
- }),
+ _listDir(),
_waitForBogusEvents()
- ]).then((_) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] watcher is ready, known files:");
- for (var file in _files.toSet()) {
- print("[$_id] ${p.relative(file, from: directory)}");
- }
- }
- _readyCompleter.complete();
- });
+ ]).then((_) => _readyCompleter.complete());
}
void close() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] watcher is closed\n${new Chain.current().terse}");
- }
if (_watchSubscription != null) _watchSubscription.cancel();
if (_initialListSubscription != null) _initialListSubscription.cancel();
_watchSubscription = null;
@@ -126,59 +101,21 @@
/// The callback that's run when [Directory.watch] emits a batch of events.
void _onBatch(List<FileSystemEvent> batch) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] ======== batch:");
- for (var event in batch) {
- print("[$_id] ${_formatEvent(event)}");
- }
-
- print("[$_id] known files:");
- for (var file in _files.toSet()) {
- print("[$_id] ${p.relative(file, from: directory)}");
- }
- }
-
// If we get a batch of events before we're ready to begin emitting events,
// it's probable that it's a batch of pre-watcher events (see issue 14373).
// Ignore those events and re-list the directory.
if (!isReady) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] not ready to emit events, re-listing directory");
- }
-
// Cancel the timer because bogus events only occur in the first batch, so
// we can fire [ready] as soon as we're done listing the directory.
_bogusEventTimer.cancel();
- _listDir().then((_) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] watcher is ready, known files:");
- for (var file in _files.toSet()) {
- print("[$_id] ${p.relative(file, from: directory)}");
- }
- }
- _readyCompleter.complete();
- });
+ _listDir().then((_) => _readyCompleter.complete());
return;
}
_sortEvents(batch).forEach((path, events) {
- var relativePath = p.relative(path, from: directory);
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] events for $relativePath:");
- for (var event in events) {
- print("[$_id] ${_formatEvent(event)}");
- }
- }
-
var canonicalEvent = _canonicalEvent(events);
events = canonicalEvent == null ?
_eventsBasedOnFileSystem(path) : [canonicalEvent];
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] canonical event for $relativePath: "
- "${_formatEvent(canonicalEvent)}");
- print("[$_id] actionable events for $relativePath: "
- "${events.map(_formatEvent)}");
- }
for (var event in events) {
if (event is FileSystemCreateEvent) {
@@ -207,9 +144,6 @@
_emitEvent(ChangeType.ADD, entity.path);
_files.add(entity.path);
}, onError: (e, stackTrace) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] got error listing $relativePath: $e");
- }
_emitError(e, stackTrace);
}, onDone: () {
_listSubscriptions.remove(subscription);
@@ -226,10 +160,6 @@
}
}
});
-
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] ======== batch complete");
- }
}
/// Sort all the events in a batch into sets based on their path.
@@ -360,15 +290,6 @@
var fileExists = new File(path).existsSync();
var dirExists = new Directory(path).existsSync();
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] checking file system for "
- "${p.relative(path, from: directory)}");
- print("[$_id] file existed: $fileExisted");
- print("[$_id] dir existed: $dirExisted");
- print("[$_id] file exists: $fileExists");
- print("[$_id] dir exists: $dirExists");
- }
-
var events = [];
if (fileExisted) {
if (fileExists) {
@@ -399,17 +320,12 @@
/// The callback that's run when the [Directory.watch] stream is closed.
void _onDone() {
- if (MacOSDirectoryWatcher.logDebugInfo) print("[$_id] stream closed");
-
_watchSubscription = null;
// If the directory still exists and we're still expecting bogus events,
// this is probably issue 14849 rather than a real close event. We should
// just restart the watcher.
if (!isReady && new Directory(directory).existsSync()) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] fake closure (issue 14849), re-opening stream");
- }
_startWatch();
return;
}
@@ -469,40 +385,12 @@
/// Emit an event with the given [type] and [path].
void _emitEvent(ChangeType type, String path) {
if (!isReady) return;
-
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] emitting $type ${p.relative(path, from: directory)}");
- }
-
_eventsController.add(new WatchEvent(type, path));
}
/// Emit an error, then close the watcher.
void _emitError(error, StackTrace stackTrace) {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[$_id] emitting error: $error\n" +
- "${new Chain.forTrace(stackTrace).terse}");
- }
_eventsController.addError(error, stackTrace);
close();
}
-
- // TODO(nweiz): remove this when issue 15042 is fixed.
- /// Return a human-friendly string representation of [event].
- String _formatEvent(FileSystemEvent event) {
- if (event == null) return 'null';
-
- var path = p.relative(event.path, from: directory);
- var type = event.isDirectory ? 'directory' : 'file';
- if (event is FileSystemCreateEvent) {
- return "create $type $path";
- } else if (event is FileSystemDeleteEvent) {
- return "delete $type $path";
- } else if (event is FileSystemModifyEvent) {
- return "modify $type $path";
- } else if (event is FileSystemMoveEvent) {
- return "move $type $path to "
- "${p.relative(event.destination, from: directory)}";
- }
- }
}
diff --git a/pubspec.yaml b/pubspec.yaml
index a16a020..a0d3000 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: watcher
-version: 0.9.5
+version: 0.9.6-dev
author: Dart Team <misc@dartlang.org>
homepage: http://github.com/dart-lang/watcher
description: >
diff --git a/test/directory_watcher/mac_os_test.dart b/test/directory_watcher/mac_os_test.dart
index bbf966a..0320e3c 100644
--- a/test/directory_watcher/mac_os_test.dart
+++ b/test/directory_watcher/mac_os_test.dart
@@ -11,8 +11,6 @@
void main() {
initConfig();
- MacOSDirectoryWatcher.logDebugInfo = true;
-
watcherFactory = (dir) => new MacOSDirectoryWatcher(dir);
setUp(createSandbox);
diff --git a/test/utils.dart b/test/utils.dart
index 6758dae..2953c98 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -117,11 +117,6 @@
///
/// If [dir] is provided, watches a subdirectory in the sandbox with that name.
void startWatcher({String dir}) {
- var testCase = currentTestCase.description;
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("starting watcher for $testCase (${new DateTime.now()})");
- }
-
// We want to wait until we're ready *after* we subscribe to the watcher's
// events.
_watcher = createWatcher(dir: dir, waitForReady: false);
@@ -131,10 +126,6 @@
// that it can be accessed synchronously after this.
_watcherEvents = new ScheduledStream(futureStream(schedule(() {
currentSchedule.onComplete.schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("stopping watcher for $testCase (${new DateTime.now()})");
- }
-
_watcher = null;
if (!_closePending) _watcherEvents.close();
@@ -301,9 +292,6 @@
dir.createSync(recursive: true);
}
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] writing file $path");
- }
new File(fullPath).writeAsStringSync(contents);
// Manually update the mock modification time for the file.
@@ -320,9 +308,6 @@
/// Schedules deleting a file in the sandbox at [path].
void deleteFile(String path) {
schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] deleting file $path");
- }
new File(p.join(_sandboxDir, path)).deleteSync();
}, "delete file $path");
}
@@ -332,10 +317,6 @@
/// If [contents] is omitted, creates an empty file.
void renameFile(String from, String to) {
schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] renaming file $from to $to");
- }
-
new File(p.join(_sandboxDir, from)).renameSync(p.join(_sandboxDir, to));
// Make sure we always use the same separator on Windows.
@@ -350,9 +331,6 @@
/// Schedules creating a directory in the sandbox at [path].
void createDir(String path) {
schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] creating directory $path");
- }
new Directory(p.join(_sandboxDir, path)).createSync();
}, "create directory $path");
}
@@ -360,9 +338,6 @@
/// Schedules renaming a directory in the sandbox from [from] to [to].
void renameDir(String from, String to) {
schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] renaming directory $from to $to");
- }
new Directory(p.join(_sandboxDir, from))
.renameSync(p.join(_sandboxDir, to));
}, "rename directory $from to $to");
@@ -371,9 +346,6 @@
/// Schedules deleting a directory in the sandbox at [path].
void deleteDir(String path) {
schedule(() {
- if (MacOSDirectoryWatcher.logDebugInfo) {
- print("[test] deleting directory $path");
- }
new Directory(p.join(_sandboxDir, path)).deleteSync(recursive: true);
}, "delete directory $path");
}