diff options
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 71c986594..1fabe7e96 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -446,8 +446,7 @@ impl SourceFileFetcher { let http_client = self.http_client.clone(); // Single pass fetch, either yields code or yields redirect. let f = async move { - match http_util::fetch_string_once(http_client, &module_url, module_etag) - .await? + match http_util::fetch_once(http_client, &module_url, module_etag).await? { FetchOnceResult::NotModified => { let source_file = @@ -526,7 +525,7 @@ impl SourceFileFetcher { let types_url = match media_type { msg::MediaType::JavaScript | msg::MediaType::JSX => get_types_url( &module_url, - source.as_bytes(), + &source, x_typescript_types.as_ref().map(String::as_str), ), _ => None, @@ -536,7 +535,7 @@ impl SourceFileFetcher { url: module_url.clone(), filename: filepath, media_type, - source_code: source.as_bytes().to_owned(), + source_code: source, types_url, }; @@ -571,13 +570,13 @@ impl SourceFileFetcher { } /// Save contents of downloaded remote file in on-disk cache for subsequent access. - fn save_source_code(&self, url: &Url, source: &str) -> std::io::Result<()> { + fn save_source_code(&self, url: &Url, source: &[u8]) -> std::io::Result<()> { let cache_key = self.deps_cache.get_cache_filename(url); // May not exist. DON'T unwrap. let _ = self.deps_cache.remove(&cache_key); - self.deps_cache.set(&cache_key, source.as_bytes()) + self.deps_cache.set(&cache_key, source) } /// Save headers related to source file to {filename}.headers.json file, @@ -1934,7 +1933,7 @@ mod tests { // it again with the cache parameters turned off. // If the fetched content changes, the cached content is used. fetcher - .save_source_code(&module_url, "changed content") + .save_source_code(&module_url, b"changed content") .unwrap(); let cached_source = fetcher .fetch_remote_source_async(&module_url, false, false, 1) |