From c411c52b43e2360343e1411f8326de96c6543238 Mon Sep 17 00:00:00 2001 From: eatradish Date: Thu, 7 Dec 2023 16:52:27 +0800 Subject: [PATCH] fix: support windows copy symlink to path --- yazi-shared/src/fs/fns.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/yazi-shared/src/fs/fns.rs b/yazi-shared/src/fs/fns.rs index 5dfc54d5..bdc5194b 100644 --- a/yazi-shared/src/fs/fns.rs +++ b/yazi-shared/src/fs/fns.rs @@ -52,9 +52,26 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver tick_tx.send(Ok(1)), - Err(e) => tick_tx.send(Err(e)), + #[cfg(unix)] + { + _ = match fs::symlink(from, to).await { + Ok(()) => tick_tx.send(Ok(1)), + Err(e) => tick_tx.send(Err(e)), + } + } + #[cfg(windows)] + { + if from.is_dir() { + _ = match fs::symlink_dir(from, to).await { + Ok(()) => tick_tx.send(Ok(1)), + Err(e) => tick_tx.send(Err(e)), + } + } else { + _ = match fs::symlink_file(from, to).await { + Ok(()) => tick_tx.send(Ok(1)), + Err(e) => tick_tx.send(Err(e)), + } + } } } else { _ = match fs::copy(from, to).await {