diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index fdf4ac9..a4f2c2b 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -1493,7 +1493,7 @@ impl Render for Yumush { self.schedule_pump(window, cx); let palette = palette(cx); let route = self.current_route; - let required = self.update.required(); + let required = self.update.required() && !crate::release::running(); let page = match route { _ if required => self.update_required(palette).into_any_element(), Route::Login | Route::Register => self.auth_page(route, cx).into_any_element(), diff --git a/crates/client/src/release.rs b/crates/client/src/release.rs index e587024..7803bfe 100644 --- a/crates/client/src/release.rs +++ b/crates/client/src/release.rs @@ -49,6 +49,27 @@ const TARGET: &str = "yumush@127.0.0.1"; const PORT: &str = "2222"; const EXTRACT: &str = "Remove-Item -Recurse -Force release -ErrorAction SilentlyContinue; New-Item -ItemType Directory release | Out-Null; tar -xmzf release.tgz -C release"; +static RUNNING: AtomicBool = AtomicBool::new(false); + +pub fn running() -> bool { + RUNNING.load(Ordering::SeqCst) +} + +struct Running; + +impl Running { + fn new() -> Self { + RUNNING.store(true, Ordering::SeqCst); + Self + } +} + +impl Drop for Running { + fn drop(&mut self) { + RUNNING.store(false, Ordering::SeqCst); + } +} + pub fn is_source(path: &Path) -> bool { path.join("crates/client/Cargo.toml").is_file() && path.join(".git").exists() } @@ -70,7 +91,11 @@ impl Build { cancel: build.cancel.clone(), child: build.child.clone(), }; - thread::spawn(move || run(&source, &cx)); + let running = Running::new(); + thread::spawn(move || { + let _running = running; + run(&source, &cx); + }); (build, rx) } diff --git a/crates/client/src/update.rs b/crates/client/src/update.rs index 37b118e..c92488c 100644 --- a/crates/client/src/update.rs +++ b/crates/client/src/update.rs @@ -15,6 +15,7 @@ pub const RESTART: &str = "--restart"; pub const TARGET: &str = env!("YUMUSH_TARGET"); const MARK: &str = concat!("yumush-target:", env!("YUMUSH_TARGET"), ";"); const CHUNK: usize = 256 << 10; +const BUILD_WAIT: std::time::Duration = std::time::Duration::from_secs(1); #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Phase { @@ -260,6 +261,9 @@ pub fn install() { }; runtime.block_on(report(&server, me, progress)); if progress == Progress::Ready && offer.required { + while crate::release::running() { + std::thread::sleep(BUILD_WAIT); + } restart(); } });