Skip to content

Commit 0e0a265

Browse files
committed
WIP symlink
1 parent b0a2a2f commit 0e0a265

File tree

1 file changed

+20
-0
lines changed
  • turbopack/crates/turbo-tasks-fs/src

1 file changed

+20
-0
lines changed

turbopack/crates/turbo-tasks-fs/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,26 @@ impl FileSystem for DiskFileSystem {
11201120
PathBuf::from(unix_to_sys(target).as_ref())
11211121
};
11221122
let full_path = full_path.into_owned();
1123+
1124+
if old_content.is_some() {
1125+
// Remove existing symlink before creating a new one. At least on Unix,
1126+
// symlink(2) fails with EEXIST if the link already exists instead of
1127+
// overwriting it
1128+
retry_blocking(full_path.clone(), |path| std::fs::remove_file(path))
1129+
.concurrency_limited(&inner.write_semaphore)
1130+
.await
1131+
.or_else(|err| {
1132+
if err.kind() == ErrorKind::NotFound {
1133+
Ok(())
1134+
} else {
1135+
Err(err)
1136+
}
1137+
})
1138+
.with_context(|| {
1139+
anyhow!("removing existing symlink {} failed", full_path.display())
1140+
})?;
1141+
}
1142+
11231143
retry_blocking(target_path, move |target_path| {
11241144
let _span = tracing::info_span!(
11251145
"write symlink",

0 commit comments

Comments
 (0)