@@ -266,12 +266,16 @@ class _WindowsDirectoryWatcher
266
266
267
267
for (var event in batch) {
268
268
if (event is FileSystemMoveEvent ) {
269
+ addEvent (
270
+ event.path, FileSystemDeleteEvent (event.path, event.isDirectory));
269
271
var destination = event.destination;
270
272
if (destination != null ) {
271
- addEvent (destination, event);
273
+ addEvent (destination,
274
+ FileSystemCreateEvent (event.path, event.isDirectory));
272
275
}
276
+ } else {
277
+ addEvent (event.path, event);
273
278
}
274
- addEvent (event.path, event);
275
279
}
276
280
277
281
return eventsForPaths;
@@ -280,6 +284,9 @@ class _WindowsDirectoryWatcher
280
284
/// Returns the canonical event from a batch of events on the same path, if
281
285
/// one exists.
282
286
///
287
+ /// The batch must be an output of [_sortEvents] which guarantees it contains
288
+ /// no [FileSystemMoveEvent] s.
289
+ ///
283
290
/// If [batch] doesn't contain any contradictory events (e.g. DELETE and
284
291
/// CREATE, or events with different values for `isDirectory` ), this returns a
285
292
/// single event that describes what happened to the path in question.
@@ -306,9 +313,7 @@ class _WindowsDirectoryWatcher
306
313
// (respectively) that will be contradictory.
307
314
if (event is FileSystemModifyEvent ) continue ;
308
315
assert (
309
- event is FileSystemCreateEvent ||
310
- event is FileSystemDeleteEvent ||
311
- event is FileSystemMoveEvent ,
316
+ event is FileSystemCreateEvent || event is FileSystemDeleteEvent ,
312
317
);
313
318
314
319
// If we previously thought this was a MODIFY, we now consider it to be a
@@ -320,9 +325,7 @@ class _WindowsDirectoryWatcher
320
325
321
326
// A CREATE event contradicts a REMOVE event and vice versa.
322
327
assert (
323
- type == FileSystemEvent .create ||
324
- type == FileSystemEvent .delete ||
325
- type == FileSystemEvent .move,
328
+ type == FileSystemEvent .create || type == FileSystemEvent .delete,
326
329
);
327
330
if (type != event.type) return null ;
328
331
}
@@ -334,8 +337,6 @@ class _WindowsDirectoryWatcher
334
337
return FileSystemDeleteEvent (batch.first.path, isDir);
335
338
case FileSystemEvent .modify:
336
339
return FileSystemModifyEvent (batch.first.path, isDir, false );
337
- case FileSystemEvent .move:
338
- return null ;
339
340
default :
340
341
throw StateError ('unreachable' );
341
342
}
0 commit comments