diff --git a/gix/src/remote/connection/fetch/error.rs b/gix/src/remote/connection/fetch/error.rs index 5034dcb5d4e..29326b3a763 100644 --- a/gix/src/remote/connection/fetch/error.rs +++ b/gix/src/remote/connection/fetch/error.rs @@ -45,6 +45,8 @@ pub enum Error { RejectShallowRemote, #[error(transparent)] NegotiationAlgorithmConfig(#[from] config::key::GenericErrorWithValue), + #[error("Failed to read remaining bytes in stream")] + ReadRemainingBytes(#[source] std::io::Error), } impl gix_protocol::transport::IsSpuriousError for Error { diff --git a/gix/src/remote/connection/fetch/receive_pack.rs b/gix/src/remote/connection/fetch/receive_pack.rs index 7634b34cf32..e0231f51a0a 100644 --- a/gix/src/remote/connection/fetch/receive_pack.rs +++ b/gix/src/remote/connection/fetch/receive_pack.rs @@ -287,7 +287,7 @@ where #[cfg(not(feature = "async-network-client"))] let has_read_to_end = { rd.stopped_at().is_some() }; if !has_read_to_end { - std::io::copy(&mut rd, &mut std::io::sink()).unwrap(); + std::io::copy(&mut rd, &mut std::io::sink()).map_err(Error::ReadRemainingBytes)?; } #[cfg(feature = "async-network-client")] {