diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-11-28 17:28:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 17:28:54 -0500 |
commit | 2d4c46c975eb916dc622cc729a1a8d397582a76f (patch) | |
tree | 445e819117acd2f94ffc9d7da7ed8e3e604435d0 /cli/npm/cache.rs | |
parent | f526513d74d34ac254aa40ef9b73238cb21c395b (diff) |
refactor: create util folder, move nap_sym to napi/sym, move http_cache to cache folder (#16857)
Diffstat (limited to 'cli/npm/cache.rs')
-rw-r--r-- | cli/npm/cache.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index 5e2f06ef7..ad6ab9db2 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -14,11 +14,13 @@ use deno_core::error::AnyError; use deno_core::parking_lot::Mutex; use deno_core::url::Url; +use crate::args::CacheSetting; use crate::cache::DenoDir; -use crate::file_fetcher::CacheSetting; -use crate::fs_util; use crate::http_util::HttpClient; -use crate::progress_bar::ProgressBar; +use crate::util::fs::canonicalize_path; +use crate::util::fs::hard_link_dir_recursive; +use crate::util::path::root_url_to_safe_local_dirname; +use crate::util::progress_bar::ProgressBar; use super::registry::NpmPackageVersionDistInfo; use super::semver::NpmVersion; @@ -162,7 +164,7 @@ impl ReadonlyNpmCache { std::fs::create_dir_all(root_dir) .with_context(|| format!("Error creating {}", root_dir.display()))?; } - Ok(crate::fs_util::canonicalize_path(root_dir)?) + Ok(canonicalize_path(root_dir)?) } // this may fail on readonly file systems, so just ignore if so @@ -227,7 +229,7 @@ impl ReadonlyNpmCache { pub fn registry_folder(&self, registry_url: &Url) -> PathBuf { self .root_dir - .join(fs_util::root_url_to_safe_local_dirname(registry_url)) + .join(root_url_to_safe_local_dirname(registry_url)) } pub fn resolve_package_folder_id_from_specifier( @@ -252,7 +254,7 @@ impl ReadonlyNpmCache { .root_dir_url .join(&format!( "{}/", - fs_util::root_url_to_safe_local_dirname(registry_url) + root_url_to_safe_local_dirname(registry_url) .to_string_lossy() .replace('\\', "/") )) @@ -457,12 +459,7 @@ impl NpmCache { with_folder_sync_lock( (id.name.as_str(), &id.version), &package_folder, - || { - fs_util::hard_link_dir_recursive( - &original_package_folder, - &package_folder, - ) - }, + || hard_link_dir_recursive(&original_package_folder, &package_folder), )?; Ok(()) } |