Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src-tauri/src/update_cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ pub async fn enter_or_abort<'a>(
enter: impl Future<Output = Result<(), String>>,
) -> Result<Install<'a>, String> {
if let Err(error) = enter.await {
install.finish_unstarted()?;
return Err(error);
return match install.finish_unstarted() {
Ok(()) => Err(error),
Err(lock) => Err(format!(
"{error} (releasing the update slot also failed: {lock})"
)),
};
}
Ok(install)
}
Expand Down Expand Up @@ -374,6 +378,27 @@ mod tests {
assert!(state.begin().is_err());
}

#[tokio::test]
async fn poisoned_slot_keeps_maintenance_entry_error() {
let state = UpdateCancel::default();
let install = state.begin().unwrap();
let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let _guard = state.0.lock().unwrap();
panic!("poison the update slot");
}));
assert!(state.0.is_poisoned());
let message = match enter_or_abort(install, ready(Err("drain failed".into()))).await {
Err(error) => error,
Ok(_) => panic!("entry failure must abort"),
};
assert!(
message.starts_with("drain failed")
&& message.contains("update cancellation state unavailable")
&& message.contains("releasing the update slot also failed"),
"{message}"
);
}

#[tokio::test]
async fn drop_while_installing_keeps_slot_and_signals_fixed_error() {
let state = UpdateCancel::default();
Expand Down
Loading