Skip to content

Commit 429f392

Browse files
feat(info): show location for Web Cache (#26205)
Closes #26181 --------- Co-authored-by: Bartek Iwańczuk <[email protected]>
1 parent fadda6a commit 429f392

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

cli/tools/info.rs

+7
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ fn print_cache_info(
126126
let registry_cache = dir.registries_folder_path();
127127
let mut origin_dir = dir.origin_data_folder_path();
128128
let deno_dir = dir.root_path_for_display().to_string();
129+
let web_cache_dir = crate::worker::get_cache_storage_dir();
129130

130131
if let Some(location) = &location {
131132
origin_dir =
@@ -143,6 +144,7 @@ fn print_cache_info(
143144
"typescriptCache": typescript_cache,
144145
"registryCache": registry_cache,
145146
"originStorage": origin_dir,
147+
"webCacheStorage": web_cache_dir,
146148
});
147149

148150
if location.is_some() {
@@ -177,6 +179,11 @@ fn print_cache_info(
177179
colors::bold("Origin storage:"),
178180
origin_dir.display()
179181
);
182+
println!(
183+
"{} {}",
184+
colors::bold("Web cache storage:"),
185+
web_cache_dir.display()
186+
);
180187
if location.is_some() {
181188
println!(
182189
"{} {}",

cli/worker.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ impl CliMainWorker {
393393
}
394394
}
395395

396+
// TODO(bartlomieju): this should be moved to some other place, added to avoid string
397+
// duplication between worker setups and `deno info` output.
398+
pub fn get_cache_storage_dir() -> PathBuf {
399+
// Note: we currently use temp_dir() to avoid managing storage size.
400+
std::env::temp_dir().join("deno_cache")
401+
}
402+
396403
#[derive(Clone)]
397404
pub struct CliMainWorkerFactory {
398405
shared: Arc<SharedWorkerState>,
@@ -529,10 +536,7 @@ impl CliMainWorkerFactory {
529536
});
530537
let cache_storage_dir = maybe_storage_key.map(|key| {
531538
// TODO(@satyarohith): storage quota management
532-
// Note: we currently use temp_dir() to avoid managing storage size.
533-
std::env::temp_dir()
534-
.join("deno_cache")
535-
.join(checksum::gen(&[key.as_bytes()]))
539+
get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()]))
536540
});
537541

538542
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out
@@ -729,10 +733,7 @@ fn create_web_worker_callback(
729733
.resolve_storage_key(&args.main_module);
730734
let cache_storage_dir = maybe_storage_key.map(|key| {
731735
// TODO(@satyarohith): storage quota management
732-
// Note: we currently use temp_dir() to avoid managing storage size.
733-
std::env::temp_dir()
734-
.join("deno_cache")
735-
.join(checksum::gen(&[key.as_bytes()]))
736+
get_cache_storage_dir().join(checksum::gen(&[key.as_bytes()]))
736737
});
737738

738739
// TODO(bartlomieju): this is cruft, update FeatureChecker to spit out

tests/specs/info/flag/041_info_flag.out

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ npm modules cache: [WILDCARD]npm
44
Emitted modules cache: [WILDCARD]gen
55
Language server registries cache: [WILDCARD]registries
66
Origin storage: [WILDCARD]location_data
7+
Web cache storage: [WILDCARD]deno_cache

tests/specs/info/flag_location/041_info_flag_location.out

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ npm modules cache: [WILDCARD]npm
44
Emitted modules cache: [WILDCARD]gen
55
Language server registries cache: [WILDCARD]registries
66
Origin storage: [WILDCARD]location_data[WILDCARD]
7+
Web cache storage: [WILDCARD]deno_cache
78
Local Storage: [WILDCARD]location_data[WILDCARD]local_storage

tests/specs/info/json/info_json.out

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"npmCache": "[WILDCARD]npm",
66
"typescriptCache": "[WILDCARD]gen",
77
"registryCache": "[WILDCARD]registries",
8-
"originStorage": "[WILDCARD]location_data"
8+
"originStorage": "[WILDCARD]location_data",
9+
"webCacheStorage": [WILDCARD]deno_cache"
910
}

0 commit comments

Comments
 (0)