Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Feb 13, 2025
1 parent 611933e commit 198311b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/daemon/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ pub async fn load_actor_bundles_from_server(
version,
}| async move {
let result = if let Ok(response) =
download_file_with_cache(url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::Default).await
download_file_with_cache(url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::NonResumable).await
{
response
} else {
warn!("failed to download bundle {network}-{version} from primary URL, trying alternative URL");
download_file_with_cache(alt_url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::Default).await?
download_file_with_cache(alt_url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::NonResumable).await?
};

let bytes = std::fs::read(&result.path)?;
Expand Down
4 changes: 2 additions & 2 deletions src/networks/actors_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ pub async fn generate_actor_bundle(output: &Path) -> anyhow::Result<()> {
version,
}| async move {
let result = if let Ok(response) =
download_file_with_cache(url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::Default).await
download_file_with_cache(url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::NonResumable).await
{
response
} else {
warn!(
"failed to download bundle {network}-{version} from primary URL, trying alternative URL"
);
download_file_with_cache(alt_url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::Default).await?
download_file_with_cache(alt_url, &ACTOR_BUNDLE_CACHE_DIR, DownloadFileOption::NonResumable).await?
};

let bytes = std::fs::read(&result.path)?;
Expand Down
2 changes: 1 addition & 1 deletion src/tool/subcommands/api_cmd/test_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ mod tests {
let cache_dir = cache_dir.clone();
async move {
let result =
download_file_with_cache(&url, &cache_dir, DownloadFileOption::Default)
download_file_with_cache(&url, &cache_dir, DownloadFileOption::NonResumable)
.await
.unwrap();
(filename, result.path)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn reader(
.pipe(tokio_util::io::StreamReader::new);
(Left(Left(stream)), content_length)
}
DownloadFileOption::Default => {
DownloadFileOption::NonResumable => {
let resp = reqwest::get(url).await?;
let content_length = resp.content_length().unwrap_or_default();
let stream = resp
Expand Down
14 changes: 8 additions & 6 deletions src/utils/net/download_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,15 @@ mod test {
async fn test_download_file_with_cache() {
let temp_dir = tempfile::tempdir().unwrap();
let url = "https://forest-snapshots.fra1.cdn.digitaloceanspaces.com/genesis/butterflynet-bafy2bzacecm7xklkq3hkc2kgm5wnb5shlxmffino6lzhh7lte5acytb7sssr4.car.zst".try_into().unwrap();
let result = download_file_with_cache(&url, temp_dir.path(), DownloadFileOption::Default)
.await
.unwrap();
let result =
download_file_with_cache(&url, temp_dir.path(), DownloadFileOption::NonResumable)
.await
.unwrap();
assert!(!result.cache_hit);
let result = download_file_with_cache(&url, temp_dir.path(), DownloadFileOption::Default)
.await
.unwrap();
let result =
download_file_with_cache(&url, temp_dir.path(), DownloadFileOption::NonResumable)
.await
.unwrap();
assert!(result.cache_hit);
}
}

0 comments on commit 198311b

Please sign in to comment.