diff options
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index c4c89fec1..0527cbac1 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -371,7 +371,9 @@ impl FileFetcher { })?; let mut headers = HashMap::new(); headers.insert("content-type".to_string(), content_type); - self.http_cache.set(specifier, headers, source.as_bytes())?; + self + .http_cache + .set(specifier, headers.clone(), source.as_bytes())?; Ok(File { local, @@ -379,7 +381,7 @@ impl FileFetcher { media_type, source: Arc::new(source), specifier: specifier.clone(), - maybe_headers: None, + maybe_headers: Some(headers), }) } @@ -433,7 +435,9 @@ impl FileFetcher { })?; let mut headers = HashMap::new(); headers.insert("content-type".to_string(), content_type); - self.http_cache.set(specifier, headers, source.as_bytes())?; + self + .http_cache + .set(specifier, headers.clone(), source.as_bytes())?; Ok(File { local, @@ -441,7 +445,7 @@ impl FileFetcher { media_type, source: Arc::new(source), specifier: specifier.clone(), - maybe_headers: None, + maybe_headers: Some(headers), }) } /// Asynchronously fetch remote source file specified by the URL following @@ -573,6 +577,14 @@ impl FileFetcher { } } + pub fn get_local_path(&self, specifier: &ModuleSpecifier) -> Option<PathBuf> { + if specifier.scheme() == "file" { + specifier.to_file_path().ok() + } else { + self.http_cache.get_cache_filename(specifier) + } + } + /// Get the location of the current HTTP cache associated with the fetcher. pub fn get_http_cache_location(&self) -> PathBuf { self.http_cache.location.clone() |