From 7bde3a7c1ecfd0c7368e7820715485f9fd11f722 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 18:09:51 -0800 Subject: [PATCH] craft-update: record an install worker that ends without an outcome at the exit start_pending_update now treats a disconnected install worker as a failed update, as tick does, so the next start says the update stopped unexpectedly. --- crates/update/src/updater.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/update/src/updater.rs b/crates/update/src/updater.rs index e7f1d788b..a19209eda 100644 --- a/crates/update/src/updater.rs +++ b/crates/update/src/updater.rs @@ -543,9 +543,13 @@ impl Updater { /// that failed and was not reported yet, is recorded, and the next start reports it /// ([`Status::InstallFailed`]). pub fn start_pending_update(&mut self) { - // An installation that finished since the last `tick`. + // An installation that finished since the last `tick`, or whose worker ended without a word. if let Some((rx, release)) = &self.install - && let Ok(outcome) = rx.try_recv() + && let Some(outcome) = match rx.try_recv() { + Ok(outcome) => Some(outcome), + Err(TryRecvError::Empty) => None, + Err(TryRecvError::Disconnected) => Some(Err(Failure::dropped())), + } { match outcome { Ok(restart) => { @@ -1454,6 +1458,15 @@ mod tests { start_answered(&mut next, &ctx, Ok(None)); assert_eq!(next.status(), &Status::InstallFailed(want.into()), "{want}"); } + // A worker that ended without sending anything. + let (_dir, paths, mut u) = with_records("0.1.0"); + let (tx, rx) = channel::>(); + u.install = Some((rx, newer())); + drop(tx); + drop(u); + let mut next = reading(&paths, "0.1.0"); + start_answered(&mut next, &ctx, Ok(None)); + assert_eq!(next.status(), &Status::InstallFailed("The update stopped unexpectedly.".into())); } }