diff --git a/src/commands.rs b/src/commands.rs index f45603d803..4d4c6f27a9 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -4065,7 +4065,7 @@ fn with_remote_callbacks(ui: &mut Ui, f: impl FnOnce(git::RemoteCallbacks<'_> let mut progress = Progress::new(Instant::now()); let ui = &ui; callback = Some(move |x: &git::Progress| { - progress.update(Instant::now(), x, &mut *ui.lock().unwrap()); + _ = progress.update(Instant::now(), x, &mut *ui.lock().unwrap()); }); } let mut callbacks = git::RemoteCallbacks::default(); diff --git a/src/progress.rs b/src/progress.rs index c97a9eb12c..194d597e38 100644 --- a/src/progress.rs +++ b/src/progress.rs @@ -1,4 +1,5 @@ use std::time::{Duration, Instant}; +use std::io; use crossterm::terminal::{Clear, ClearType}; use jujutsu_lib::git; @@ -20,19 +21,19 @@ impl Progress { } } - pub fn update(&mut self, now: Instant, progress: &git::Progress, ui: &mut Ui) { + pub fn update(&mut self, now: Instant, progress: &git::Progress, ui: &mut Ui) -> io::Result<()> { use std::fmt::Write as _; if progress.overall == 1.0 { - _ = write!(ui, "\r{}", Clear(ClearType::CurrentLine)); - return; + write!(ui, "\r{}", Clear(ClearType::CurrentLine))?; + return Ok(()); } let rate = progress .bytes_downloaded .and_then(|x| self.rate.update(now, x)); if now < self.next_print { - return; + return Ok(()); } self.next_print = now.min(self.next_print + Duration::from_secs(1) / UPDATE_HZ); @@ -54,8 +55,9 @@ impl Progress { draw_progress(progress.overall, &mut self.buffer, bar_width); self.buffer.push(']'); - _ = write!(ui, "{}", self.buffer); - _ = ui.flush(); + write!(ui, "{}", self.buffer)?; + ui.flush()?; + Ok(()) } }