feat(info): show location for Web Cache (#26205)

Closes #26181 

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
haturau 2024-11-20 10:04:48 +09:00 committed by GitHub
parent fadda6a8fb
commit 429f3929fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 9 deletions

View File

@ -126,6 +126,7 @@ fn print_cache_info(
let registry_cache = dir.registries_folder_path(); let registry_cache = dir.registries_folder_path();
let mut origin_dir = dir.origin_data_folder_path(); let mut origin_dir = dir.origin_data_folder_path();
let deno_dir = dir.root_path_for_display().to_string(); let deno_dir = dir.root_path_for_display().to_string();
let web_cache_dir = crate::worker::get_cache_storage_dir();
if let Some(location) = &location { if let Some(location) = &location {
origin_dir = origin_dir =
@ -143,6 +144,7 @@ fn print_cache_info(
"typescriptCache": typescript_cache, "typescriptCache": typescript_cache,
"registryCache": registry_cache, "registryCache": registry_cache,
"originStorage": origin_dir, "originStorage": origin_dir,
"webCacheStorage": web_cache_dir,
}); });
if location.is_some() { if location.is_some() {
@ -177,6 +179,11 @@ fn print_cache_info(
colors::bold("Origin storage:"), colors::bold("Origin storage:"),
origin_dir.display() origin_dir.display()
); );
println!(
"{} {}",
colors::bold("Web cache storage:"),
web_cache_dir.display()
);
if location.is_some() { if location.is_some() {
println!( println!(
"{} {}", "{} {}",

View File

@ -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)] #[derive(Clone)]
pub struct CliMainWorkerFactory { pub struct CliMainWorkerFactory {
shared: Arc<SharedWorkerState>, shared: Arc<SharedWorkerState>,
@ -529,10 +536,7 @@ impl CliMainWorkerFactory {
}); });
let cache_storage_dir = maybe_storage_key.map(|key| { let cache_storage_dir = maybe_storage_key.map(|key| {
// TODO(@satyarohith): storage quota management // TODO(@satyarohith): storage quota management
// Note: we currently use temp_dir() to avoid managing storage size. get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()]))
std::env::temp_dir()
.join("deno_cache")
.join(checksum::gen(&[key.as_bytes()]))
}); });
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out // 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); .resolve_storage_key(&args.main_module);
let cache_storage_dir = maybe_storage_key.map(|key| { let cache_storage_dir = maybe_storage_key.map(|key| {
// TODO(@satyarohith): storage quota management // TODO(@satyarohith): storage quota management
// Note: we currently use temp_dir() to avoid managing storage size. get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()]))
std::env::temp_dir()
.join("deno_cache")
.join(checksum::gen(&[key.as_bytes()]))
}); });
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out // TODO(bartlomieju): this is cruft, update FeatureChecker to spit out

View File

@ -4,3 +4,4 @@ npm modules cache: [WILDCARD]npm
Emitted modules cache: [WILDCARD]gen Emitted modules cache: [WILDCARD]gen
Language server registries cache: [WILDCARD]registries Language server registries cache: [WILDCARD]registries
Origin storage: [WILDCARD]location_data Origin storage: [WILDCARD]location_data
Web cache storage: [WILDCARD]deno_cache

View File

@ -4,4 +4,5 @@ npm modules cache: [WILDCARD]npm
Emitted modules cache: [WILDCARD]gen Emitted modules cache: [WILDCARD]gen
Language server registries cache: [WILDCARD]registries Language server registries cache: [WILDCARD]registries
Origin storage: [WILDCARD]location_data[WILDCARD] Origin storage: [WILDCARD]location_data[WILDCARD]
Web cache storage: [WILDCARD]deno_cache
Local Storage: [WILDCARD]location_data[WILDCARD]local_storage Local Storage: [WILDCARD]location_data[WILDCARD]local_storage

View File

@ -5,5 +5,6 @@
"npmCache": "[WILDCARD]npm", "npmCache": "[WILDCARD]npm",
"typescriptCache": "[WILDCARD]gen", "typescriptCache": "[WILDCARD]gen",
"registryCache": "[WILDCARD]registries", "registryCache": "[WILDCARD]registries",
"originStorage": "[WILDCARD]location_data" "originStorage": "[WILDCARD]location_data",
"webCacheStorage": [WILDCARD]deno_cache"
} }