File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
sdk_nnbd/lib/_internal/vm/bin Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,9 @@ class _FileSystemWatcher {
217217 bool getIsDir (event) {
218218 if (Platform .isWindows) {
219219 // Windows does not get 'isDir' as part of the event.
220- return FileSystemEntity .isDirectorySync (getPath (event));
220+ // Links should also be skipped.
221+ return FileSystemEntity .isDirectorySync (getPath (event)) &&
222+ ! FileSystemEntity .isLinkSync (getPath (event));
221223 }
222224 return (event[0 ] & FileSystemEvent ._isDir) != 0 ;
223225 }
Original file line number Diff line number Diff line change @@ -219,7 +219,9 @@ class _FileSystemWatcher {
219219 bool getIsDir (event) {
220220 if (Platform .isWindows) {
221221 // Windows does not get 'isDir' as part of the event.
222- return FileSystemEntity .isDirectorySync (getPath (event));
222+ // Links should also be skipped.
223+ return FileSystemEntity .isDirectorySync (getPath (event)) &&
224+ ! FileSystemEntity .isLinkSync (getPath (event));
223225 }
224226 return (event[0 ] & FileSystemEvent ._isDir) != 0 ;
225227 }
Original file line number Diff line number Diff line change @@ -275,10 +275,36 @@ testRelativeLinksSync() {
275275 tempDirectory.deleteSync (recursive: true );
276276}
277277
278+ testIsDir () async {
279+ if (! Platform .isWindows && ! Platform .isLinux && ! Platform .isMacOS) return ;
280+ Directory sandbox = Directory .systemTemp.createTempSync ();
281+ Directory dir = new Directory (sandbox.path + Platform .pathSeparator + "dir" );
282+ dir.createSync ();
283+ File target = new File (sandbox.path + Platform .pathSeparator + "target" );
284+ target.createSync ();
285+
286+ final eventCompleter = new Completer <FileSystemEvent >();
287+ var subscription;
288+ subscription = dir.watch ().listen ((FileSystemEvent event) {
289+ if (event.path.endsWith ('link' )) {
290+ eventCompleter.complete (event);
291+ subscription.cancel ();
292+ }
293+ });
294+ Link link = new Link (dir.path + Platform .pathSeparator + "link" );
295+ link.createSync (target.path);
296+ final event = await eventCompleter.future;
297+ // Link should not be marked as Dir.
298+ Expect .isFalse (event.isDirectory);
299+
300+ sandbox.deleteSync (recursive: true );
301+ }
302+
278303main () {
279304 testCreateSync ();
280305 testCreateLoopingLink ();
281306 testRenameSync ();
282307 testLinkErrorSync ();
283308 testRelativeLinksSync ();
309+ testIsDir ();
284310}
You can’t perform that action at this time.
0 commit comments