added version number, fixed infinite update loop

This commit is contained in:
Uber Veng
2026-05-22 01:26:21 +07:00
parent 3fafc71cdd
commit b395df590e
6 changed files with 70 additions and 4 deletions

View File

@@ -35,8 +35,26 @@ async fn main() -> Result<()> {
let (event_tx, mut event_rx) = mpsc::unbounded_channel();
let mut app = app::App::new(config, event_tx.clone());
// Detect failed update: if the previous run wrote an expected version but
// the actual version didn't change, the replacement didn't work.
// Show an error and skip the update check to break any infinite loop.
let update_ok = match updater::take_update_target() {
Some(expected) if expected != env!("CARGO_PKG_VERSION") => {
app.error = Some(format!(
"Обновление не применилось: ожидалась v{expected}, \
запущена v{}. Проверьте, что в релизе загружен правильный бинарник.",
env!("CARGO_PKG_VERSION")
));
false
}
_ => true,
};
app.load_menu().await;
app.check_update();
if update_ok {
app.check_update();
}
let res = run_app(&mut terminal, &mut app, &mut event_rx).await;