summaryrefslogtreecommitdiff
path: root/cli/file_fetcher.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-10-11 08:26:22 +1100
committerGitHub <noreply@github.com>2021-10-11 08:26:22 +1100
commita7baf5f2bbb50dc0cb571de141b800b9155faca7 (patch)
tree4bebaabd1d3ed4595e8a388e0fae559bb5558974 /cli/file_fetcher.rs
parent5a8a989b7815023f33a1e3183a55cc8999af5d98 (diff)
refactor: integrate deno_graph into CLI (#12369)
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r--cli/file_fetcher.rs20
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()