Fixed auto update

This commit is contained in:
Uber Veng
2026-05-22 00:24:19 +07:00
parent cb85dfa039
commit 65e189c913
5 changed files with 25 additions and 19 deletions

View File

@@ -19,7 +19,8 @@ pub enum Event {
StructuredFinished(i32),
UpdateAvailable(updater::UpdateInfo),
UpdateProgress(u64),
UpdateDone,
/// Carries the exe path captured before the binary was replaced.
UpdateDone(std::path::PathBuf),
UpdateError(String),
}
@@ -40,7 +41,8 @@ pub struct App {
pub event_tx: UnboundedSender<Event>,
/// When set, main loop suspends ratatui, runs the command, then restores.
pub pending_exec: Option<PendingExec>,
pub pending_restart: bool,
/// Exe path to exec after update; captured before the binary was replaced.
pub pending_restart: Option<std::path::PathBuf>,
}
pub enum Popup {
@@ -104,7 +106,7 @@ impl App {
popup: None,
event_tx,
pending_exec: None,
pending_restart: false,
pending_restart: None,
}
}
@@ -241,11 +243,11 @@ impl App {
}
Ok(false)
}
Event::UpdateDone => {
Event::UpdateDone(exe_path) => {
if let Some(Popup::Updating { status, .. }) = &mut self.popup {
*status = UpdatingStatus::Done;
}
self.pending_restart = true;
self.pending_restart = Some(exe_path);
Ok(false)
}
Event::UpdateError(msg) => {
@@ -507,8 +509,8 @@ impl App {
)
.await
{
Ok(()) => {
let _ = tx2.send(Event::UpdateDone);
Ok(exe_path) => {
let _ = tx2.send(Event::UpdateDone(exe_path));
}
Err(e) => {
let _ =