mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-15 23:12:15 +00:00
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.
This commit is contained in:
1 parent
2411acae5e
commit
7bde3a7c1e
1 file changed
+15
-2
@@ -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::<Result<Restart, Failure>>();
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user