Avoid canonicalizing executables on Windows (#5446)

## Summary

If you have an executable path on a network share path (like
`\\some-host\some-share\...\python.exe`), canonicalizing it adds the
`\\?` prefix, but dunce cannot safely strip it.

This PR changes the Windows logic to avoid canonicalizing altogether. We
don't really expect symlinks on Windows, so it seems unimportant to
resolve them.

Closes: https://github.com/astral-sh/uv/issues/5440.
This commit is contained in:
Charlie Marsh 2024-07-26 08:57:33 -04:00 committed by GitHub
parent 967fcdbb83
commit 8b8f34ac21
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 125 deletions

View file

@ -15,7 +15,7 @@ pub struct Timestamp(std::time::SystemTime);
impl Timestamp {
/// Return the [`Timestamp`] for the given path.
pub fn from_path(path: impl AsRef<Path>) -> std::io::Result<Self> {
let metadata = path.as_ref().metadata()?;
let metadata = fs_err::metadata(path.as_ref())?;
Ok(Self::from_metadata(&metadata))
}