fix(core): Use junction crate on windows for symlinks

This commit is contained in:
LynithDev 2026-07-14 19:48:16 +02:00
parent 79497c0cc6
commit ae5fc08892
5 changed files with 20 additions and 8 deletions

11
Cargo.lock generated
View file

@ -3116,6 +3116,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "junction"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "160f2eade097f30263b548aae5deb12ad349c909baa710fa24b92c9090b2e006"
dependencies = [
"scopeguard",
"windows-sys 0.61.2",
]
[[package]]
name = "keyboard-types"
version = "0.8.3"
@ -4455,6 +4465,7 @@ dependencies = [
"dunce",
"futures-lite",
"futures-util",
"junction",
"sanitize-filename",
"serde",
"serde_json",

View file

@ -95,6 +95,7 @@ sanitize-filename = { version = "=0.6.0" }
regex = { version = "=1.12.3" }
parking_lot = { version = "=0.12.5" }
dunce = { version = "=1.0.5" }
junction = { version = "=2.0.0" }
bytes = { version = "=1.11.1" }
indicatif = { version = "=0.18.4", features = [ "tokio" ]}
sysinfo = { version = "=0.39.5" }

View file

@ -1,4 +1,5 @@
#![recursion_limit = "256"]
#[cfg(debug_assertions)]
pub mod dev;

View file

@ -37,3 +37,6 @@ serde_json.workspace = true
dunce.workspace = true
bytes.workspace = true
[target.'cfg(windows)'.dependencies]
junction.workspace = true

View file

@ -393,19 +393,15 @@ pub async fn symlink_dir(
let original = original.as_ref();
let link = link.as_ref();
// tokio has no async junction API, so the Windows path runs the blocking
// std call on the blocking pool; Unix uses tokio's async symlink directly.
#[cfg(windows)]
{
let path = link.to_string_lossy().to_string();
let original = original.to_path_buf();
let link = link.to_path_buf();
return tokio::task::spawn_blocking(move || {
std::os::windows::fs::junction_point(&original, &link)
})
.await
.map_err(std::io::Error::other)?
.map_err(|e| IOError::PathIOError { source: e, path });
return tokio::task::spawn_blocking(move || junction::create(&original, &link))
.await
.map_err(std::io::Error::other)?
.map_err(|e| IOError::PathIOError { source: e, path });
}
#[cfg(not(windows))]