-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-iotriagedIssue has been triaged by sub teamIssue has been triaged by sub team
Description
Another one :) @mraleph
If you watch a very-recently-renamed directory on Linux, it can do two surprising things:
- report events with the path from before the rename
- close itself because it thinks it just got deleted
import 'dart:io';
void main() async {
final directory = Directory.systemTemp.createTempSync();
directory.watch().listen(
(e) => print('for ${directory.path}: $e'),
onDone: () => print('done ${directory.path}'));
File('${directory.path}/f').createSync();
final newName = '${directory.path}-renamed';
directory.rename(newName);
Directory(newName).watch().listen(
(e) => print('for $newName: $e'),
onDone: () => print('done ${newName}'));
File('$newName/g').createSync();
await Future.delayed(Duration(seconds: 1));
}prints
for /tmp/FBUFLC: FileSystemCreateEvent('/tmp/FBUFLC/f', isDirectory=false)
for /tmp/FBUFLC-renamed: FileSystemCreateEvent('/tmp/FBUFLC/f', isDirectory=false)
for /tmp/FBUFLC: FileSystemDeleteEvent('/tmp/FBUFLC')
for /tmp/FBUFLC-renamed: FileSystemDeleteEvent('/tmp/FBUFLC')
done /tmp/FBUFLC
done /tmp/FBUFLC-renamed
- the creation of the file "f" is reported by both watchers, notice
Directory('/tmp/FBUFLC-renamed').watchreporting an event from a different (named) directory. - the delete in the old location is also reported by both watchers, and causes both watchers to close, even though /tmp/FBUFLC-renamed continues to exist and it would be nice to receive events for it :)
If you know about this then you can work around it, so I guess at least it's worth documenting.
But I wonder if the VM can do any better, e.g. perhaps it could filter out events with the wrong prefix, perhaps it could continue watching or restart watching past a delete event for the wrong prefix?
There is a related but different issue if the watched directory is a subdirectory of a renamed directory, I will open a different issue for that next.
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-iotriagedIssue has been triaged by sub teamIssue has been triaged by sub team