feat(updater): option to not restart after install (#3299)

* feat(updater): option to not restart after install

* More platform cfg

* Add the same function for `UpdaterBuilder`

* Fix missing `#[cfg(windows)]`

* Mark `current_exe_args` cfg(windows)

* Mark `on_before_exit` cfg(windows)

* Mark `installer_args` cfg(windows)

* Note about `installer_arg` apply to both

* Remove current args and restart together

* Only build needed bundle on windows as well

* Remove `/NS` since it breaks the msi updater

* Add launch updater debug log

* Add a folder to test updates

* Remove unused `#[allow(unused)]`

* Format

* messed up git stage

* Add change file

* Clean up

* Disable NSIS compression for API example

* Bump wry for v1 test to pull in https://github.com/tauri-apps/wry/pull/1703

* format

* Make typescript happy

* Close new update on destroy
This commit is contained in:
Tony
2026-07-21 18:25:16 +08:00
committed by GitHub
parent 3fb27bf13a
commit ab7489c964
16 changed files with 328 additions and 188 deletions
+5
View File
@@ -77,7 +77,9 @@
},
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDE5QzMxNjYwNTM5OEUwNTgKUldSWTRKaFRZQmJER1h4d1ZMYVA3dnluSjdpN2RmMldJR09hUFFlZDY0SlFqckkvRUJhZDJVZXAK",
"dangerousInsecureTransportProtocol": true,
"endpoints": [
"http://localhost:5173/updater-test/updater.json",
"https://tauri-update-server.vercel.app/update/{{target}}/{{current_version}}"
]
}
@@ -99,6 +101,9 @@
"localePath": "locales/pt-BR.wxl"
}
}
},
"nsis": {
"compression": "none"
}
},
"iOS": {
+19 -11
View File
@@ -1,12 +1,18 @@
<script>
import { check } from '@tauri-apps/plugin-updater'
<script lang="ts">
import { check, Update } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'
import { onDestroy } from 'svelte'
export let onMessage
let { onMessage } = $props()
let isChecking, isInstalling, newUpdate
let totalSize = 0,
downloadedSize = 0
let isChecking = $state(false)
let isInstalling = $state(false)
let newUpdate = $state<Update | undefined>()
let totalSize = $state(0)
let downloadedSize = $state(0)
let progress = $derived(
totalSize ? Math.round((downloadedSize / totalSize) * 100) : 0
)
async function checkUpdate() {
isChecking = true
@@ -31,10 +37,10 @@
isInstalling = true
downloadedSize = 0
try {
await newUpdate.downloadAndInstall((downloadProgress) => {
await newUpdate!.downloadAndInstall((downloadProgress) => {
switch (downloadProgress.event) {
case 'Started':
totalSize = downloadProgress.data.contentLength
totalSize = downloadProgress.data.contentLength!
break
case 'Progress':
downloadedSize += downloadProgress.data.chunkLength
@@ -54,14 +60,16 @@
}
}
$: progress = totalSize ? Math.round((downloadedSize / totalSize) * 100) : 0
onDestroy(() => {
newUpdate?.close()
})
</script>
<div class="flex children:grow children:h10">
{#if !isChecking && !newUpdate}
<button class="btn" on:click={checkUpdate}>Check update</button>
<button class="btn" onclick={checkUpdate}>Check update</button>
{:else if !isInstalling && newUpdate}
<button class="btn" on:click={install}>Install update</button>
<button class="btn" onclick={install}>Install update</button>
{:else}
<div class="progress">
<span>{progress}%</span>
+5
View File
@@ -0,0 +1,5 @@
*
!.gitignore
!README.md
!updater.json
+10
View File
@@ -0,0 +1,10 @@
To test the updater:
1. Comment out `verify_signature` inside `plugins/updater/src/updater.rs`
2. Run `pnpm tauri build --debug` to build the bundles
3. Copy the bundle you want to test to this folder (`examples/api/updater-test/`)
4. Run `pnpm tauri dev` and open the Updater tab to check
If the bundle you're testing doesn't exist in the `updater.json` yet, add it manually and welcome to open an PR
> The `updater.json` and debug bundles will be served by `vite`
+11
View File
@@ -0,0 +1,11 @@
{
"version": "2.1.0",
"notes": "Test update!",
"pub_date": "2026-03-01T14:04:20+00:00",
"platforms": {
"windows-x86_64": {
"signature": "",
"url": "http://localhost:5173/updater-test/Tauri API_2.0.0_x64_en-US.msi"
}
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ export default defineConfig(async () => {
port: 5173,
strictPort: true,
fs: {
allow: ['.', '../../tooling/api/dist']
allow: ['.']
}
}
}