8000 crates/common: fix error checking in Gcs fetcher impl, check request error in CachingDownloader by twitchyliquid64 · Pull Request #86 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/common/src/fetchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ impl FetchResponse for Result<google_cloud_storage::read_object::ReadObjectRespo
self.is_ok()
}
fn error_for_status(self) -> Result<Self, Self::Error> {
Ok(self)
match self {
Ok(_) => Ok(self),
Err(e) => Err(e),
}
}

async fn bytes(self) -> Result<Bytes, Self::Error> {
Expand Down
4 changes: 3 additions & 1 deletion crates/common/src/file_cache.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::Tee;
use crate::fetchers::{self, FetchUrl};
use crate::fetchers::{self, FetchResponse, FetchUrl};

use either::Either;
use ot::OpTracker;
Expand Down Expand Up @@ -227,6 +227,8 @@ impl<B: fetchers::FetchBackend> CachingDownloader<B> for (&B, &FileCache) {
.0
.execute(self.0.get(url).map_err(Either::Right)?)
.await
.map_err(Either::Right)?
.error_for_status()
.map_err(Either::Right)?;

self.1.write_through(&filename, sha256, &mut r, op).await
Expand Down
0