Skip to content

Commit 354470f

Browse files
committed
Oops, fix forgetting to handle Windows symlinks at top-level
Signed-off-by: Alex Saveau <[email protected]>
1 parent 961768e commit 354470f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

fuc_engine/src/ops/copy.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ fn schedule_copies<
107107
}
108108
.map_io_err(|| format!("Failed to read metadata for file: {from:?}"))?;
109109

110-
#[cfg(unix)]
111110
if from_metadata.is_dir() {
112111
use std::os::unix::fs::{DirBuilderExt, MetadataExt};
113112
match fs::DirBuilder::new().mode(from_metadata.mode()).create(&to) {
@@ -126,8 +125,19 @@ fn schedule_copies<
126125
fs::hard_link(&link, &to)
127126
.map_io_err(|| format!("Failed to create hard link: {to:?} -> {link:?}"))?;
128127
} else {
129-
std::os::unix::fs::symlink(&link, &to)
130-
.map_io_err(|| format!("Failed to create symlink: {to:?} -> {link:?}"))?;
128+
let run = || {
129+
#[cfg(unix)]
130+
{
131+
std::os::unix::fs::symlink(&link, &to)
132+
}
133+
#[cfg(windows)]
134+
if fs::metadata(&link)?.file_type().is_dir() {
135+
std::os::windows::fs::symlink_dir(&link, to)
136+
} else {
137+
std::os::windows::fs::symlink_file(&link, to)
138+
}
139+
};
140+
run().map_io_err(|| format!("Failed to create symlink: {to:?} -> {link:?}"))?;
131141
}
132142
} else if hard_link {
133143
match fs::remove_file(&to) {
@@ -139,13 +149,6 @@ fn schedule_copies<
139149
} else {
140150
fs::copy(&from, &to).map_io_err(|| format!("Failed to copy file: {from:?}"))?;
141151
}
142-
143-
#[cfg(not(unix))]
144-
if from_metadata.is_dir() {
145-
copy.run((from, to))?;
146-
} else {
147-
fs::copy(&from, &to).map_io_err(|| format!("Failed to copy file: {from:?}"))?;
148-
}
149152
}
150153
Ok(())
151154
}

0 commit comments

Comments
 (0)