Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ disallowed-methods = [
"std::fs::soft_link",
"std::fs::symlink_metadata",
"std::fs::write",
"std::os::unix::fs::symlink",
"std::os::windows::fs::symlink_dir",
"std::os::windows::fs::symlink_file",
]
4 changes: 2 additions & 2 deletions crates/uv-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,13 +653,13 @@ impl Cache {
let dst = dst.as_ref();

// Attempt to create the symlink directly.
match std::os::unix::fs::symlink(&src, dst) {
match fs_err::os::unix::fs::symlink(&src, dst) {
Ok(()) => Ok(()),
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {
// Create a symlink, using a temporary file to ensure atomicity.
let temp_dir = tempfile::tempdir_in(dst.parent().unwrap())?;
let temp_file = temp_dir.path().join("link");
std::os::unix::fs::symlink(&src, &temp_file)?;
fs_err::os::unix::fs::symlink(&src, &temp_file)?;

// Move the symlink into the target location.
fs_err::rename(&temp_file, dst)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io:
#[cfg(unix)]
pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
// Attempt to create the symlink directly.
match std::os::unix::fs::symlink(src.as_ref(), dst.as_ref()) {
match fs_err::os::unix::fs::symlink(src.as_ref(), dst.as_ref()) {
Ok(()) => Ok(()),
Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {
// Create a symlink, using a temporary file to ensure atomicity.
let temp_dir = tempfile::tempdir_in(dst.as_ref().parent().unwrap())?;
let temp_file = temp_dir.path().join("link");
std::os::unix::fs::symlink(src, &temp_file)?;
fs_err::os::unix::fs::symlink(src, &temp_file)?;

// Move the symlink into the target location.
fs_err::rename(&temp_file, dst.as_ref())?;
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-install-wheel/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,14 @@ fn synchronized_copy(from: &Path, to: &Path, locks: &Locks) -> std::io::Result<(

#[cfg(unix)]
fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> {
std::os::unix::fs::symlink(original, link)
fs_err::os::unix::fs::symlink(original, link)
}

#[cfg(windows)]
fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> {
if original.as_ref().is_dir() {
std::os::windows::fs::symlink_dir(original, link)
fs_err::os::windows::fs::symlink_dir(original, link)
} else {
std::os::windows::fs::symlink_file(original, link)
fs_err::os::windows::fs::symlink_file(original, link)
}
}
2 changes: 1 addition & 1 deletion crates/uv-python/src/downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ impl ManagedPythonDownload {
// to that date do not.
#[cfg(unix)]
{
match std::os::unix::fs::symlink(
match fs_err::os::unix::fs::symlink(
format!("python{}.{}", self.key.major, self.key.minor),
extracted.join("bin").join("python"),
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-virtualenv/src/virtualenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ pub(crate) fn create(
&& interpreter.markers().os_name() == "posix"
&& interpreter.markers().sys_platform() != "darwin"
{
match std::os::unix::fs::symlink("lib", location.join("lib64")) {
match fs_err::os::unix::fs::symlink("lib", location.join("lib64")) {
Ok(()) => {}
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {}
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/it/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ fn build_with_symlink() -> Result<()> {
requires = ["hatchling"]
build-backend = "hatchling.build"
"#})?;
std::os::unix::fs::symlink(
fs_err::os::unix::fs::symlink(
context.temp_dir.child("pyproject.toml.real"),
context.temp_dir.child("pyproject.toml"),
)?;
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/it/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3723,7 +3723,7 @@ fn launcher_with_symlink() -> Result<()> {
);

#[cfg(windows)]
if let Err(error) = std::os::windows::fs::symlink_file(
if let Err(error) = fs_err::os::windows::fs::symlink_file(
context.venv.join("Scripts\\simple_launcher.exe"),
context.temp_dir.join("simple_launcher.exe"),
) {
Expand All @@ -3736,7 +3736,7 @@ fn launcher_with_symlink() -> Result<()> {
}

#[cfg(unix)]
std::os::unix::fs::symlink(
fs_err::os::unix::fs::symlink(
context.venv.join("bin/simple_launcher"),
context.temp_dir.join("simple_launcher"),
)?;
Expand Down Expand Up @@ -8123,7 +8123,7 @@ fn install_relocatable() -> Result<()> {
#[cfg(unix)]
{
let script_symlink_path = context.temp_dir.join("black");
std::os::unix::fs::symlink(script_path, script_symlink_path.clone())?;
fs_err::os::unix::fs::symlink(script_path, script_symlink_path.clone())?;
Command::new(script_symlink_path.as_os_str())
.assert()
.success()
Expand Down
3 changes: 2 additions & 1 deletion crates/uv/tests/it/python_find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ fn python_required_python_major_minor() {

// Symlink it to `python3.11`.
fs_err::create_dir_all(context.temp_dir.child("child")).unwrap();
std::os::unix::fs::symlink(path, context.temp_dir.child("child").join("python3.11")).unwrap();
fs_err::os::unix::fs::symlink(path, context.temp_dir.child("child").join("python3.11"))
.unwrap();

// Find `python3.11`, which is `>=3.11.4`.
uv_snapshot!(context.filters(), context.python_find().arg(">=3.11.4, <3.12").env(EnvVars::UV_TEST_PYTHON_PATH, context.temp_dir.child("child").path()), @r###"
Expand Down
Loading