perf: don't re-download package tarball to global cache if local node_modules folder exists for package (#16005)

This commit is contained in:
David Sherret 2022-09-23 17:35:48 -04:00 committed by GitHub
parent 12306022da
commit f6a9b49dfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 115 additions and 45 deletions

View file

@ -198,6 +198,18 @@ impl NpmCache {
id: &NpmPackageId,
dist: &NpmPackageVersionDistInfo,
registry_url: &Url,
) -> Result<(), AnyError> {
self
.ensure_package_inner(id, dist, registry_url)
.await
.with_context(|| format!("Failed caching npm package '{}'.", id))
}
async fn ensure_package_inner(
&self,
id: &NpmPackageId,
dist: &NpmPackageVersionDistInfo,
registry_url: &Url,
) -> Result<(), AnyError> {
let package_folder = self.readonly.package_folder(id, registry_url);
if package_folder.exists()