File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
turbopack/crates/turbo-tasks-fs/src Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1127,6 +1127,26 @@ impl FileSystem for DiskFileSystem {
11271127 PathBuf :: from ( unix_to_sys ( target) . as_ref ( ) )
11281128 } ;
11291129 let full_path = full_path. into_owned ( ) ;
1130+
1131+ if old_content. is_some ( ) {
1132+ // Remove existing symlink before creating a new one. At least on Unix,
1133+ // symlink(2) fails with EEXIST if the link already exists instead of
1134+ // overwriting it
1135+ retry_blocking ( full_path. clone ( ) , |path| std:: fs:: remove_file ( path) )
1136+ . concurrency_limited ( & inner. write_semaphore )
1137+ . await
1138+ . or_else ( |err| {
1139+ if err. kind ( ) == ErrorKind :: NotFound {
1140+ Ok ( ( ) )
1141+ } else {
1142+ Err ( err)
1143+ }
1144+ } )
1145+ . with_context ( || {
1146+ anyhow ! ( "removing existing symlink {} failed" , full_path. display( ) )
1147+ } ) ?;
1148+ }
1149+
11301150 retry_blocking ( target_path, move |target_path| {
11311151 let _span = tracing:: info_span!(
11321152 "write symlink" ,
You can’t perform that action at this time.
0 commit comments