Skip to content

Commit

Permalink
Update ext.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Oct 24, 2024
1 parent 84938d6 commit 84adaa2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions crates/warpgate/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ pub fn create_cache_key(url: &str, seed: Option<&str>) -> String {
format!("{:x}", sha.finalize())
}

pub fn determine_cache_extension(value: &str) -> &str {
pub fn determine_cache_extension(value: &str) -> Option<&str> {
for ext in [".toml", ".json", ".jsonc", ".yaml", ".yml", ".wasm", ".txt"] {
if value.ends_with(ext) {
return ext;
return Some(ext);
}
}

""
None
}

pub async fn download_from_url_to_file(
Expand Down
2 changes: 1 addition & 1 deletion crates/warpgate/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ fn send_request(
let cache_key = create_cache_key(&input.url, None);
let cache_path = data.cache_dir.join("requests").join(format!(
"{cache_key}{}",
determine_cache_extension(&input.url)
determine_cache_extension(&input.url).unwrap_or_default()
));

// Data to collect
Expand Down
6 changes: 3 additions & 3 deletions crates/warpgate/src/loader.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::client::{create_http_client_with_options, HttpOptions};
use crate::endpoints::*;
use crate::error::WarpgateError;
use crate::helpers::{
determine_cache_extension, download_from_url_to_file, move_or_unpack_download,
create_cache_key, determine_cache_extension, download_from_url_to_file, move_or_unpack_download,
};
use crate::id::Id;
use crate::{create_cache_key, endpoints::*};
use once_cell::sync::OnceCell;
use starbase_archive::is_supported_archive_extension;
use starbase_styles::color;
Expand Down Expand Up @@ -155,7 +155,7 @@ impl PluginLoader {
id.as_str().replace(['/', '@', '.', ' '], ""),
if is_latest { "-latest-" } else { "-" },
create_cache_key(url, self.seed.as_deref()),
determine_cache_extension(url),
determine_cache_extension(url).unwrap_or(".wasm"),
))
}

Expand Down

0 comments on commit 84adaa2

Please sign in to comment.