Skip to content

Commit e6cb030

Browse files
CopilotBrooooooklyn
andcommitted
Ensure shim files are created in AlreadyExists case and improve error matching readability
Co-authored-by: Brooooooklyn <3468483+Brooooooklyn@users.noreply.github.com>
1 parent 973b6e9 commit e6cb030

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

crates/vite_install/src/package_manager.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ async fn download_package_manager(
405405
cleanup_err
406406
);
407407
}
408+
// Ensure shim files exist - they should have been created by the other process,
409+
// but create them if they're missing to ensure a complete installation
410+
if !is_exists_file(&bin_file)?
411+
|| !is_exists_file(bin_file.with_extension("cmd"))?
412+
|| !is_exists_file(bin_file.with_extension("ps1"))?
413+
{
414+
tracing::debug!("Shim files missing, creating them");
415+
create_shim_files(package_manager_type, &bin_prefix).await?;
416+
}
408417
Ok(install_dir)
409418
}
410419
Err(e) => Err(e.into()),
@@ -417,18 +426,20 @@ async fn remove_dir_all_force(path: impl AsRef<Path>) -> Result<(), std::io::Err
417426
match remove_dir_all(path).await {
418427
Ok(()) => Ok(()),
419428
Err(e) => {
420-
// Ignore errors that can occur during concurrent test execution:
421-
// - NotFound: directory was already removed
422-
// - DirectoryNotEmpty: another process is actively using/removing the directory
423-
// Using ErrorKind for cross-platform compatibility instead of raw OS error codes
424-
if matches!(
425-
e.kind(),
426-
std::io::ErrorKind::NotFound | std::io::ErrorKind::DirectoryNotEmpty
427-
) {
428-
tracing::debug!("Ignoring directory removal error (likely concurrent access): {}", e);
429-
Ok(())
430-
} else {
431-
Err(e)
429+
// Ignore errors that can occur during concurrent test execution
430+
// Using ErrorKind for cross-platform compatibility
431+
match e.kind() {
432+
// Directory was already removed by another process
433+
std::io::ErrorKind::NotFound => {
434+
tracing::debug!("Ignoring NotFound error (concurrent removal): {}", e);
435+
Ok(())
436+
}
437+
// Another process is actively using/removing the directory
438+
std::io::ErrorKind::DirectoryNotEmpty => {
439+
tracing::debug!("Ignoring DirectoryNotEmpty error (concurrent access): {}", e);
440+
Ok(())
441+
}
442+
_ => Err(e),
432443
}
433444
}
434445
}

0 commit comments

Comments
 (0)