diff --git a/src/api/sync.rs b/src/api/sync.rs index 1d7e445..44d533b 100644 --- a/src/api/sync.rs +++ b/src/api/sync.rs @@ -238,15 +238,16 @@ fn symlink_or_rename(src: &Path, dst: &Path) -> Result<(), std::io::Error> { return Ok(()); } - let src = make_relative(src, dst); + let rel_src = make_relative(src, dst); #[cfg(target_os = "windows")] - std::os::windows::fs::symlink_file(src, dst)?; + { + if std::os::windows::fs::symlink_file(rel_src, dst).is_err() { + std::fs::rename(src, dst)?; + } + } #[cfg(target_family = "unix")] - std::os::unix::fs::symlink(src, dst)?; - - #[cfg(not(any(target_family = "unix", target_os = "windows")))] - std::fs::rename(src, dst)?; + std::os::unix::fs::symlink(rel_src, dst)?; Ok(()) } diff --git a/src/api/tokio.rs b/src/api/tokio.rs index fa29dc0..8d558cb 100644 --- a/src/api/tokio.rs +++ b/src/api/tokio.rs @@ -244,15 +244,16 @@ fn symlink_or_rename(src: &Path, dst: &Path) -> Result<(), std::io::Error> { return Ok(()); } - let src = make_relative(src, dst); + let rel_src = make_relative(src, dst); #[cfg(target_os = "windows")] - std::os::windows::fs::symlink_file(src, dst)?; + { + if std::os::windows::fs::symlink_file(rel_src, dst).is_err() { + std::fs::rename(src, dst)?; + } + } #[cfg(target_family = "unix")] - std::os::unix::fs::symlink(src, dst)?; - - #[cfg(not(any(target_family = "unix", target_os = "windows")))] - std::fs::rename(src, dst)?; + std::os::unix::fs::symlink(rel_src, dst)?; Ok(()) }