Thanks to visit codestin.com
Credit goes to github.com

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
3 changes: 3 additions & 0 deletions pkgs/watcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
the file was created immediately before the watcher was created. Now, if the
file exists when the watcher is created then this modify event is not sent.
This matches the Linux native and polling (Windows) watchers.
- Bug fix: with `DirectoryWatcher` on Windows, the last of a rapid sequence of
modifications in a newly-created directory was sometimes dropped. Make it
reliably report the last modification.
- Bug fix: with `DirectoryWatcher` on Windows, a move over an existing file was
reported incorrectly. For example, if `a` and `b` already exist, then `a` is
moved onto `b`, it would be reported as three events: delete `a`, delete `b`,
Expand Down
11 changes: 10 additions & 1 deletion pkgs/watcher/lib/src/directory_watcher/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,16 @@ class _WindowsDirectoryWatcher
types.contains(EventType.createFile)) {
// Combine events of type [EventType.modifyFile] and
// [EventType.createFile] to one event.
type = EventType.createFile;

// The file can be already in `_files` if it's in a recently-created
// directory, the directory list finds it and adds it. In that case a pair
// of "create"+"modify" should be reported as "modify".
//
// Otherwise, it's a new file, "create"+"modify" should be reported as
// "create".
type = _files.contains(batch.first.path)
? EventType.modifyFile
: EventType.createFile;
} else {
// There are incompatible event types, check the filesystem.
return null;
Expand Down
4 changes: 0 additions & 4 deletions pkgs/watcher/test/directory_watcher/end_to_end_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ void endToEndTests({required bool isNative}) {
print('Ignoring expected failure for Linux native watcher.');
return;
}
if (Platform.isWindows && isNative) {
print('Ignoring expected failure for Windows native watcher.');
return;
}

// Write the file operations before the failure to a log, fail the test.
final logTemp = Directory.systemTemp.createTempSync();
Expand Down