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 @@ -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" ,
You can’t perform that action at this time.
0 commit comments