added version number, fixed infinite update loop
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user