From 3ff1827a12557a601da22d138beb97e8647d5d6e Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 12 Nov 2023 10:44:09 +0100 Subject: [PATCH] fix: Allow multiple packs to be received one after another. (#972) Previously it would be difficult to perform another fetch operation on the same connection as the final flush packet after a pack wouldn't be consumed. This has now been mitigated by consuming it in the one place where knoweldge about this specialty exists. --- gix/src/remote/connection/fetch/receive_pack.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gix/src/remote/connection/fetch/receive_pack.rs b/gix/src/remote/connection/fetch/receive_pack.rs index 26e71f4ca36..4064772ac0e 100644 --- a/gix/src/remote/connection/fetch/receive_pack.rs +++ b/gix/src/remote/connection/fetch/receive_pack.rs @@ -281,10 +281,19 @@ where })), options, )?; + // Assure the final flush packet is consumed. + #[cfg(feature = "async-network-client")] + let has_read_to_end = { rd.get_ref().stopped_at().is_some() }; + #[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(); + } #[cfg(feature = "async-network-client")] { reader = rd.into_inner(); } + #[cfg(not(feature = "async-network-client"))] { reader = rd;