Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/watcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [3.3, dev]
sdk: [3.4, dev]
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
Expand Down
5 changes: 5 additions & 0 deletions pkgs/watcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
exhaustion, "Directory watcher closed unexpectedly", much less likely. The old
implementation which does not use a separate Isolate is available as
`DirectoryWatcher(path, runInIsolateOnWindows: false)`.
- `DirectoryWatcher` on Windows: if buffer exhaustion does happen, emit a
"modify" event for all know files instead of an exception.
- Document behavior on Linux if the system watcher limit is hit.
- Require Dart SDK `^3.4.0`.
- Bug fix: native `DirectoryWatcher` implementations now consistently handle
links as files, instead of sometimes reading through them and sometimes
reporting them as files. The polling `DirectoryWatcher` still reads through
Expand All @@ -33,6 +36,8 @@
- Bug fix: with `DirectoryWatcher` on Windows, new links to directories were
sometimes incorrectly handled as actual directories. Now they are reported
as files, matching the behavior of the Linux and MacOS watchers.
- Bug fix: unify `DirectoryWatcher` implementation on Windows with the MacOS
implementation, addressing various race conditions around directory renames.
- Bug fix: new `DirectoryWatcher` implementation on Linux that fixes various
issues: tracking failure following subdirectory move, incorrect events when
there are changes in a recently-moved subdirectory, incorrect events due to
Expand Down
158 changes: 0 additions & 158 deletions pkgs/watcher/benchmark/path_set.dart

This file was deleted.

12 changes: 5 additions & 7 deletions pkgs/watcher/lib/src/directory_watcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import 'directory_watcher/windows_resubscribable_watcher.dart';
///
/// On Windows, the underlying SDK `Directory.watch` fails if too many events
/// are received while Dart is busy, for example during a long-running
/// synchronous operation. When this happens, some events are dropped.
/// `DirectoryWatcher` restarts the watch and sends a `FileSystemException` with
/// the message "Directory watcher closed unexpectedly" on the event stream. The
/// code using the watcher needs to do additional work to account for the
/// dropped events, for example by recomputing interesting files from scratch.
/// By default, the watcher is started in a separate isolate to make this less
/// likely. Pass `runInIsolateOnWindows = false` to not launch an isolate.
/// synchronous operation. When this happens, watching is re-established and a
/// "modify" event is emitted for any file still present that lost tracking, in
/// case it changed. By default, the watcher is started in a separate isolate to
/// make this less likely. Pass `runInIsolateOnWindows = false` to not launch an
/// isolate.
///
/// On Linux, the underlying SDK `Directory.watch` fails if the system limit on
/// watchers has been reached. If this happens the SDK exception is thrown, it
Expand Down
17 changes: 15 additions & 2 deletions pkgs/watcher/lib/src/directory_watcher/directory_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import 'dart:io';

import 'package:path/path.dart' as p;

import '../utils.dart';

extension DirectoryRobustRecursiveListing on Directory {
/// Lists the given directory recursively ignoring not-found or access errors.
///
Expand Down Expand Up @@ -233,3 +231,18 @@ const _errorInvalidName = 123;
const _errorBadPathName = 161;
const _errorAlreadyExists = 183;
const _errorFilenameExedRange = 206;

extension IgnoringError<T> on Stream<T> {
/// Ignore all errors of type [E] emitted by the given stream.
///
/// Everything else gets forwarded through as-is.
Stream<T> ignoring<E>() {
return transform(StreamTransformer<T, T>.fromHandlers(
handleError: (error, st, sink) {
if (error is! E) {
sink.addError(error, st);
}
},
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.

import '../../unix_paths.dart';
import '../paths.dart';

/// Tree of event paths relative to the watched path.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import 'dart:async';
import 'dart:io';

import '../../event.dart';
import '../../unix_paths.dart';
import '../../utils.dart';
import '../../event_batching.dart';
import '../../paths.dart';
import '../../testing.dart';

/// Watches a directory with the native Linux watcher.
///
Expand Down Expand Up @@ -88,7 +89,7 @@ class NativeWatch {
logForTesting?.call('NativeWatch(),$watchedDirectory');
_subscription = watchedDirectory
.watch()
.batchAndConvertEvents()
.batchNearbyMicrotasksAndConvertEvents()
.listen(_onData, onError: _onError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import 'dart:io';

import '../../event.dart';
import '../../unix_paths.dart';
import '../../utils.dart';
import '../../paths.dart';
import '../../testing.dart';
import '../../watch_event.dart';
import 'native_watch.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import 'dart:async';

import '../../unix_paths.dart';
import '../../utils.dart';
import '../../paths.dart';
import '../../testing.dart';
import '../../watch_event.dart';
import 'watch_tree.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import 'dart:io';

import '../../unix_paths.dart';
import '../../utils.dart';
import '../../paths.dart';
import '../../testing.dart';
import '../../watch_event.dart';
import 'event_tree.dart';
import '../event_tree.dart';

/// MacOS directory tree.
/// MacOS or Windows directory tree.
///
/// Tracks state for a single directory and maintains child [DirectoryTree]
/// instances for subdirectories.
Expand Down
Loading