Skip to content

Commit

Permalink
Remove unnecessary ConstructableFileSystemEvent classes (dart-lang/wa…
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan authored May 10, 2023
1 parent 6895509 commit aa09575
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 98 deletions.
2 changes: 1 addition & 1 deletion pkgs/watcher/.github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
sdk: [2.19.0, dev]
sdk: [3.0.0, dev]
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
Expand Down
5 changes: 5 additions & 0 deletions pkgs/watcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.0-dev

- Require Dart SDK >= 3.0.0
- Remove usage of redundant ConstructableFileSystemEvent classes.
-
## 1.0.3-dev

- Require Dart SDK >= 2.19
Expand Down
71 changes: 0 additions & 71 deletions pkgs/watcher/lib/src/constructable_file_system_event.dart

This file was deleted.

22 changes: 10 additions & 12 deletions pkgs/watcher/lib/src/directory_watcher/mac_os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'dart:io';

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

import '../constructable_file_system_event.dart';
import '../directory_watcher.dart';
import '../path_set.dart';
import '../resubscribable.dart';
Expand Down Expand Up @@ -285,12 +284,11 @@ class _MacOSDirectoryWatcher
// [_eventsBasedOnFileSystem] will handle this correctly by producing a
// DELETE event followed by a CREATE event if the directory exists.
if (isDir) return null;
return ConstructableFileSystemCreateEvent(batch.first.path, false);
return FileSystemCreateEvent(batch.first.path, false);
case FileSystemEvent.delete:
return ConstructableFileSystemDeleteEvent(batch.first.path, isDir);
return FileSystemDeleteEvent(batch.first.path, isDir);
case FileSystemEvent.modify:
return ConstructableFileSystemModifyEvent(
batch.first.path, isDir, false);
return FileSystemModifyEvent(batch.first.path, isDir, false);
default:
throw StateError('unreachable');
}
Expand All @@ -312,26 +310,26 @@ class _MacOSDirectoryWatcher
var events = <FileSystemEvent>[];
if (fileExisted) {
if (fileExists) {
events.add(ConstructableFileSystemModifyEvent(path, false, false));
events.add(FileSystemModifyEvent(path, false, false));
} else {
events.add(ConstructableFileSystemDeleteEvent(path, false));
events.add(FileSystemDeleteEvent(path, false));
}
} else if (dirExisted) {
if (dirExists) {
// If we got contradictory events for a directory that used to exist and
// still exists, we need to rescan the whole thing in case it was
// replaced with a different directory.
events.add(ConstructableFileSystemDeleteEvent(path, true));
events.add(ConstructableFileSystemCreateEvent(path, true));
events.add(FileSystemDeleteEvent(path, true));
events.add(FileSystemCreateEvent(path, true));
} else {
events.add(ConstructableFileSystemDeleteEvent(path, true));
events.add(FileSystemDeleteEvent(path, true));
}
}

if (!fileExisted && fileExists) {
events.add(ConstructableFileSystemCreateEvent(path, false));
events.add(FileSystemCreateEvent(path, false));
} else if (!dirExisted && dirExists) {
events.add(ConstructableFileSystemCreateEvent(path, true));
events.add(FileSystemCreateEvent(path, true));
}

return events;
Expand Down
22 changes: 10 additions & 12 deletions pkgs/watcher/lib/src/directory_watcher/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'dart:io';

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

import '../constructable_file_system_event.dart';
import '../directory_watcher.dart';
import '../path_set.dart';
import '../resubscribable.dart';
Expand Down Expand Up @@ -306,12 +305,11 @@ class _WindowsDirectoryWatcher

switch (type) {
case FileSystemEvent.create:
return ConstructableFileSystemCreateEvent(batch.first.path, isDir);
return FileSystemCreateEvent(batch.first.path, isDir);
case FileSystemEvent.delete:
return ConstructableFileSystemDeleteEvent(batch.first.path, isDir);
return FileSystemDeleteEvent(batch.first.path, isDir);
case FileSystemEvent.modify:
return ConstructableFileSystemModifyEvent(
batch.first.path, isDir, false);
return FileSystemModifyEvent(batch.first.path, isDir, false);
case FileSystemEvent.move:
return null;
default:
Expand Down Expand Up @@ -342,26 +340,26 @@ class _WindowsDirectoryWatcher
var events = <FileSystemEvent>[];
if (fileExisted) {
if (fileExists) {
events.add(ConstructableFileSystemModifyEvent(path, false, false));
events.add(FileSystemModifyEvent(path, false, false));
} else {
events.add(ConstructableFileSystemDeleteEvent(path, false));
events.add(FileSystemDeleteEvent(path, false));
}
} else if (dirExisted) {
if (dirExists) {
// If we got contradictory events for a directory that used to exist and
// still exists, we need to rescan the whole thing in case it was
// replaced with a different directory.
events.add(ConstructableFileSystemDeleteEvent(path, true));
events.add(ConstructableFileSystemCreateEvent(path, true));
events.add(FileSystemDeleteEvent(path, true));
events.add(FileSystemCreateEvent(path, true));
} else {
events.add(ConstructableFileSystemDeleteEvent(path, true));
events.add(FileSystemDeleteEvent(path, true));
}
}

if (!fileExisted && fileExists) {
events.add(ConstructableFileSystemCreateEvent(path, false));
events.add(FileSystemCreateEvent(path, false));
} else if (!dirExisted && dirExists) {
events.add(ConstructableFileSystemCreateEvent(path, true));
events.add(FileSystemCreateEvent(path, true));
}

return events;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/watcher/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: watcher
version: 1.0.3-dev
version: 1.1.0-dev
description: >-
A file system watcher. It monitors changes to contents of directories and
sends notifications when files have been added, removed, or modified.
repository: https://github.com/dart-lang/watcher

environment:
sdk: '>=2.19.0 <3.0.0'
sdk: ^3.0.0

dependencies:
async: ^2.5.0
Expand Down

0 comments on commit aa09575

Please sign in to comment.