diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-08-01 20:49:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 00:49:09 +0000 |
commit | 1cefa831fd74b14121494045a347024502d74e34 (patch) | |
tree | cc7791cf674e427fe4165262db416e6c537e99a3 /cli/lsp/registries.rs | |
parent | 36ae37604a0ddab4349df6eb6fafb8ae39fd20fc (diff) |
feat(unstable): optional `deno_modules` directory (#19977)
Closes #15633
Diffstat (limited to 'cli/lsp/registries.rs')
-rw-r--r-- | cli/lsp/registries.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs index 9586997c5..0219653bd 100644 --- a/cli/lsp/registries.rs +++ b/cli/lsp/registries.rs @@ -13,6 +13,7 @@ use super::path_to_regex::StringOrVec; use super::path_to_regex::Token; use crate::args::CacheSetting; +use crate::cache::GlobalHttpCache; use crate::cache::HttpCache; use crate::file_fetcher::FileFetcher; use crate::http_util::HttpClient; @@ -415,13 +416,15 @@ enum VariableItems { pub struct ModuleRegistry { origins: HashMap<String, Vec<RegistryConfiguration>>, file_fetcher: FileFetcher, + http_cache: Arc<GlobalHttpCache>, } impl ModuleRegistry { pub fn new(location: PathBuf, http_client: Arc<HttpClient>) -> Self { - let http_cache = HttpCache::new(location); + // the http cache should always be the global one for registry completions + let http_cache = Arc::new(GlobalHttpCache::new(location)); let mut file_fetcher = FileFetcher::new( - http_cache, + http_cache.clone(), CacheSetting::RespectHeaders, true, http_client, @@ -433,6 +436,7 @@ impl ModuleRegistry { Self { origins: HashMap::new(), file_fetcher, + http_cache, } } @@ -517,10 +521,7 @@ impl ModuleRegistry { "cache-control".to_string(), "max-age=604800, immutable".to_string(), ); - self - .file_fetcher - .http_cache - .set(specifier, headers_map, &[])?; + self.http_cache.set(specifier, headers_map, &[])?; } let file = fetch_result?; let config: RegistryConfigurationJson = serde_json::from_str(&file.source)?; |