Skip to content

[feat] Windows - Suppress restarting app after installing update #15055

@Bingdom

Description

@Bingdom

Describe the problem

Using Windows, I am using the updater plugin to run updates, which runs immediately on app launch. I only download the update.

I only apply the update when the window gets closed.

struct PendingUpdate(Mutex<Option<(tauri_plugin_updater::Update, Vec<u8>)>>);

// Another rust function that gets invoked, checks and downloads the update.
// Stores it into PendingUpdate.

pub fn run() {
 tuari::Builder::default()
// ...
.on_window_event(|window, event| {
            // Apply the update when the window got closed
            match event {
                tauri::WindowEvent::CloseRequested { api, .. } => {
                    let state: tauri::State<'_, PendingUpdate> = window.state::<PendingUpdate>();
                    let pending = state.0.lock().unwrap().take();
                    if let Some((update, bytes)) = pending {
                        let _ = update.install(bytes);
                    }
                    std::process::exit(0);
                }
                _ => {}
            }
}

This works great if the user's intention was to apply the update. I.e. Update now -> Close window.

However, if the intention was to fully close the app- i.e. clicking on the 'x' button, then the app should not re-appear.

Describe the solution you'd like

A reopen flag that could be passed into install(), which prevents the app from reopening on Windows after the installer completes.

Alternatives considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions