1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

perf: hard link npm cache (#22773)

This commit is contained in:
Divy Srivastava 2024-03-07 23:40:19 +05:30 committed by GitHub
parent 8df47882c9
commit e0c9102b49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -332,8 +332,12 @@ async fn sync_resolution_with_fs(
.with_context(|| format!("Creating '{}'", folder_path.display()))?;
let cache_folder = cache
.package_folder_for_name_and_version(&package.id.nv, &registry_url);
// for now copy, but in the future consider hard linking
copy_dir_recursive(&cache_folder, &package_path)?;
if hard_link_dir_recursive(&cache_folder, &package_path).is_err() {
// Fallback to copying the directory.
//
// Also handles EXDEV when when trying to hard link across volumes.
copy_dir_recursive(&cache_folder, &package_path)?;
}
// write out a file that indicates this folder has been initialized
fs::write(initialized_file, "")?;
// finally stop showing the progress bar