@@ -30,10 +30,8 @@ class _EventBatcher {
3030 final List <Event > events = [];
3131 Timer ? timer;
3232
33- void addEvent (FileSystemEvent event, void Function () callback) {
34- final convertedEvent = Event .checkAndConvert (event);
35- if (convertedEvent == null ) return ;
36- events.add (convertedEvent);
33+ void addEvent (Event event, void Function () callback) {
34+ events.add (event);
3735 timer? .cancel ();
3836 timer = Timer (_batchDelay, callback);
3937 }
@@ -166,8 +164,28 @@ class _WindowsDirectoryWatcher
166164 );
167165 }
168166
169- void _onEvent (FileSystemEvent event ) {
167+ void _onEvent (FileSystemEvent fileSystemEvent ) {
170168 assert (isReady);
169+ final event = Event .checkAndConvert (fileSystemEvent);
170+ if (event == null ) return ;
171+ if (event.type == EventType .moveFile) {
172+ _batchEvent (Event .delete (event.path));
173+ final destination = event.destination;
174+ if (destination != null ) {
175+ _batchEvent (Event .createFile (destination));
176+ }
177+ } else if (event.type == EventType .moveDirectory) {
178+ _batchEvent (Event .delete (event.path));
179+ final destination = event.destination;
180+ if (destination != null ) {
181+ _batchEvent (Event .createDirectory (destination));
182+ }
183+ } else {
184+ _batchEvent (event);
185+ }
186+ }
187+
188+ void _batchEvent (Event event) {
171189 final batcher = _eventBatchers.putIfAbsent (event.path, _EventBatcher .new );
172190 batcher.addEvent (event, () {
173191 _eventBatchers.remove (event.path);
@@ -268,10 +286,6 @@ class _WindowsDirectoryWatcher
268286
269287 for (var event in batch) {
270288 addEvent (event.path, event);
271- final destination = event.destination;
272- if (destination != null ) {
273- addEvent (destination, event);
274- }
275289 }
276290
277291 return eventsForPaths;
@@ -300,11 +314,6 @@ class _WindowsDirectoryWatcher
300314 return null ;
301315 }
302316
303- // Move events are always resolved by checking the filesystem.
304- if (type == EventType .moveFile || type == EventType .moveDirectory) {
305- return null ;
306- }
307-
308317 return batch.firstWhere ((e) => e.type == type);
309318 }
310319
0 commit comments