Skip to content

Commit 44faa01

Browse files
committed
Fixed error by also using trait object in remote::fetch::Prepare::receive
and expose a new `pub(crate)` fn `receive_inner` Signed-off-by: Jiahao XU <[email protected]>
1 parent 59ccbe3 commit 44faa01

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

gix/src/clone/fetch/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{clone::PrepareFetch, features::progress::DynNestedProgressToNestedProgress};
1+
use crate::clone::PrepareFetch;
22

33
/// The error returned by [`PrepareFetch::fetch_only()`].
44
#[derive(Debug, thiserror::Error)]
@@ -120,7 +120,7 @@ impl PrepareFetch {
120120
f(&mut connection).map_err(|err| Error::RemoteConnection(err))?;
121121
}
122122
connection
123-
.prepare_fetch(&mut progress, {
123+
.prepare_fetch(&mut *progress, {
124124
let mut opts = self.fetch_options.clone();
125125
if !opts.extra_refspecs.contains(&head_refspec) {
126126
opts.extra_refspecs.push(head_refspec)
@@ -143,7 +143,7 @@ impl PrepareFetch {
143143
message: reflog_message.clone(),
144144
})
145145
.with_shallow(self.shallow.clone())
146-
.receive(DynNestedProgressToNestedProgress(progress), should_interrupt)
146+
.receive_inner(progress, should_interrupt)
147147
.await?;
148148

149149
util::append_config_to_repo_config(repo, config);

gix/src/remote/connection/fetch/receive_pack.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,28 @@ where
7474
///
7575
#[gix_protocol::maybe_async::maybe_async]
7676
#[allow(clippy::drop_non_drop)]
77-
pub async fn receive<P>(mut self, mut progress: P, should_interrupt: &AtomicBool) -> Result<Outcome, Error>
77+
pub async fn receive<P>(self, mut progress: P, should_interrupt: &AtomicBool) -> Result<Outcome, Error>
7878
where
7979
P: gix_features::progress::NestedProgress,
8080
P::SubProgress: 'static,
8181
{
82+
self.receive_inner(&mut progress, should_interrupt)
83+
}
84+
85+
#[gix_protocol::maybe_async::maybe_async]
86+
#[allow(clippy::drop_non_drop)]
87+
pub(crate) async fn receive_inner(
88+
mut self,
89+
progress: &mut dyn crate::DynNestedProgress,
90+
should_interrupt: &AtomicBool,
91+
) -> Result<Outcome, Error> {
8292
let _span = gix_trace::coarse!("fetch::Prepare::receive()");
8393
let mut con = self.con.take().expect("receive() can only be called once");
8494

8595
let handshake = &self.ref_map.handshake;
8696
let protocol_version = handshake.server_protocol_version;
8797

8898
let fetch = gix_protocol::Command::Fetch;
89-
let progress = &mut progress;
9099
let repo = con.remote.repo;
91100
let fetch_features = {
92101
let mut f = fetch.default_features(protocol_version, &handshake.capabilities);
@@ -379,17 +388,14 @@ fn add_shallow_args(
379388
Ok((shallow_commits, shallow_lock))
380389
}
381390

382-
fn setup_remote_progress<P>(
383-
progress: &mut P,
391+
fn setup_remote_progress(
392+
progress: &mut dyn crate::DynNestedProgress,
384393
reader: &mut Box<dyn gix_protocol::transport::client::ExtendedBufRead + Unpin + '_>,
385394
should_interrupt: &AtomicBool,
386-
) where
387-
P: gix_features::progress::NestedProgress,
388-
P::SubProgress: 'static,
389-
{
395+
) {
390396
use gix_protocol::transport::client::ExtendedBufRead;
391397
reader.set_progress_handler(Some(Box::new({
392-
let mut remote_progress = progress.add_child_with_id("remote", ProgressId::RemoteProgress.into());
398+
let mut remote_progress = progress.add_child_with_id("remote".to_string(), ProgressId::RemoteProgress.into());
393399
// SAFETY: Ugh, so, with current Rust I can't declare lifetimes in the involved traits the way they need to
394400
// be and I also can't use scoped threads to pump from local scopes to an Arc version that could be
395401
// used here due to the this being called from sync AND async code (and the async version doesn't work

0 commit comments

Comments
 (0)