From 6356329b37282178701c0064a4a2cd04286a51e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 20 Nov 2024 00:18:55 +0100 Subject: dedup, rename, fix tests --- cli/tools/info.rs | 8 ++++---- cli/worker.rs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'cli') diff --git a/cli/tools/info.rs b/cli/tools/info.rs index c138d03d4..34e191850 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -126,7 +126,7 @@ fn print_cache_info( let registry_cache = dir.registries_folder_path(); let mut origin_dir = dir.origin_data_folder_path(); let deno_dir = dir.root_path_for_display().to_string(); - let deno_cache_dir = std::env::temp_dir().join("deno_cache"); + let web_cache_dir = crate::worker::get_cache_storage_dir(); if let Some(location) = &location { origin_dir = @@ -144,7 +144,7 @@ fn print_cache_info( "typescriptCache": typescript_cache, "registryCache": registry_cache, "originStorage": origin_dir, - "denoCacheDir": deno_cache_dir, + "webCacheStorage": web_cache_dir, }); if location.is_some() { @@ -181,8 +181,8 @@ fn print_cache_info( ); println!( "{} {}", - colors::bold("Deno Cache:"), - deno_cache_dir.display() + colors::bold("Web Cache storage:"), + web_cache_dir.display() ); if location.is_some() { println!( diff --git a/cli/worker.rs b/cli/worker.rs index 3b09714d5..0b07bb4bf 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -393,6 +393,13 @@ impl CliMainWorker { } } +// TODO(bartlomieju): this should be moved to some other place, added to avoid string +// duplication between worker setups and `deno info` output. +pub fn get_cache_storage_dir() -> PathBuf { + // Note: we currently use temp_dir() to avoid managing storage size. + std::env::temp_dir().join("deno_cache") +} + #[derive(Clone)] pub struct CliMainWorkerFactory { shared: Arc, @@ -529,10 +536,7 @@ impl CliMainWorkerFactory { }); let cache_storage_dir = maybe_storage_key.map(|key| { // TODO(@satyarohith): storage quota management - // Note: we currently use temp_dir() to avoid managing storage size. - std::env::temp_dir() - .join("deno_cache") - .join(checksum::gen(&[key.as_bytes()])) + get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()])) }); // TODO(bartlomieju): this is cruft, update FeatureChecker to spit out @@ -729,10 +733,7 @@ fn create_web_worker_callback( .resolve_storage_key(&args.main_module); let cache_storage_dir = maybe_storage_key.map(|key| { // TODO(@satyarohith): storage quota management - // Note: we currently use temp_dir() to avoid managing storage size. - std::env::temp_dir() - .join("deno_cache") - .join(checksum::gen(&[key.as_bytes()])) + get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()])) }); // TODO(bartlomieju): this is cruft, update FeatureChecker to spit out -- cgit v1.2.3