fix: support windows copy symlink to path

This commit is contained in:
eatradish 2023-12-07 16:52:27 +08:00 committed by sxyazi
parent 7a3c70f144
commit c411c52b43
No known key found for this signature in database

View file

@ -52,10 +52,27 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver<Result<u64,
async move { async move {
if is_symlink { if is_symlink {
#[cfg(unix)]
{
_ = match fs::symlink(from, to).await { _ = match fs::symlink(from, to).await {
Ok(()) => tick_tx.send(Ok(1)), Ok(()) => tick_tx.send(Ok(1)),
Err(e) => tick_tx.send(Err(e)), 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 { } else {
_ = match fs::copy(from, to).await { _ = match fs::copy(from, to).await {
Ok(len) => tick_tx.send(Ok(len)), Ok(len) => tick_tx.send(Ok(len)),