dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

Link::existsSync() fails on windows when symlink to a folder exists, but with different case. #57016

Open sohrab-niche opened 2 weeks ago

sohrab-niche commented 2 weeks ago

Link::existsSync() fails on windows when symlink to a folder exists, but with different case.

For example, the Link object is created with path A:\b\Hello. But the symlink to the folder already exists as A:\b\hello.

Process info

Memory CPU Elapsed time Command line
14 MB -- dart.exe
437 MB -- dart.exe
14 MB -- dart.exe
154 MB -- dart.exe
93 MB -- dart.exe
dart-github-bot commented 2 weeks ago

Summary: The Link::existsSync() method on Windows incorrectly fails to detect a symlink to a folder when the case of the symlink path differs from the actual folder path. For example, a symlink named "A:\b\Hello" fails to find a folder named "A:\b\hello".

mraleph commented 2 weeks ago

You would need to provide a reproduction. I have tried simple test:

import 'dart:io';

void main() async {
  Link('c:\\src\\aaa').createSync('C:\\src\\dart');
  print(Link('c:\\src\\aAa').existsSync());
}

and it does not reveal any case sensitivity.

That being said: it might be that A:\b\Hello is treated in a case-sensitive manner by the OS due to various reasons. You can try to check that using command like this (see https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity#inspect-current-case-sensitivity):

fsutil.exe file queryCaseSensitiveInfo <path>