fix #14740: linux update check and upload safety

- Linux: ask the feed for the windows-x86_64 entry only to learn the
  version; report it (the settings show the .deb hint) without storing a
  pending update or announcing it. install_update refuses off Windows.
- Background checks re-check is_due once the running lock is held.
- Check errors read "Update-Prüfung fehlgeschlagen: …".
- Settings: a failed follow-up getUpdate() never hides a found update; an
  unknown canSelfUpdate() shows it without an install button.
- An upload the CRM accepted but that could not be saved locally names
  the CRM id and is refused for re-upload until the app restarts.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-09 10:50:12 +01:00
co-authored by Claude Opus 5.5
parent 083edf32a2
commit a0f89454f9
4 changed files with 273 additions and 41 deletions
+38 -12
View File
@@ -71,6 +71,24 @@
let installProgress = $state<UpdateProgress | null>(null)
let installError = $state('')
/** The version to show as "available", if any. On Windows this comes
* from `pendingUpdate` (kept in sync with the banner by `get_update`/
* `update-available`, so it is current even without a manual check).
* Everywhere else the backend never stores `pendingUpdate` for a found
* update (see `updater::check_outcome`), so a manual check's own result
* is the only source. It is also the fallback whenever `pendingUpdate`
* is not known (e.g. the follow-up `getUpdate()` failed, or
* `canSelfUpdate()` failed): a found update is never hidden. */
let availableVersion = $derived(
(selfUpdateCapable === true ? pendingUpdate?.version : undefined) ??
(checkResult?.status === 'available' ? checkResult.version : undefined),
)
/** Whether the install button/progress can be offered for
* `availableVersion`: only once this build is confirmed able to
* self-update AND `pendingUpdate` (with its `can_install` guard) is
* actually known. */
let canOfferInstall = $derived(selfUpdateCapable === true && pendingUpdate !== null)
onMount(() => {
load()
backendServer()
@@ -97,20 +115,22 @@
/** "Nach Updates suchen": runs the same check as the background loop,
* immediately. An available update also arrives via `update-available`
* (so the main window's banner shows it too), but is applied here as
* well in case that event is missed. */
* (so the main window's banner shows it too, on Windows), but is applied
* here as well in case that event is missed. That follow-up fetch is
* best-effort: if it fails, the "available" result just found still
* stands — it must never be replaced by that unrelated failure. */
async function checkUpdateNow() {
checking = true
checkResult = null
try {
const result = await checkForUpdateNow()
checkResult = result
if (result.status === 'available') pendingUpdate = await getUpdate()
checkResult = await checkForUpdateNow()
} catch (err) {
checkResult = { status: 'error', message: errorText(err) }
} finally {
checking = false
return
}
if (checkResult.status === 'available') await refreshPendingUpdate()
checking = false
}
async function refreshPendingUpdate() {
@@ -470,24 +490,30 @@
<span class="error">{checkResult.message}</span>
{/if}
</div>
{#if pendingUpdate && selfUpdateCapable !== null}
{#if availableVersion !== undefined}
<div class="update-available">
<span>Update verfügbar (v{pendingUpdate.version})</span>
{#if selfUpdateCapable}
<span>Update verfügbar (v{availableVersion})</span>
{#if canOfferInstall}
{#if installing}
<span>{updateProgressText(installProgress)}</span>
{:else}
<button class="btn primary small" disabled={!pendingUpdate.can_install} onclick={installUpdateNow}>
<button
class="btn primary small"
disabled={!pendingUpdate?.can_install}
onclick={installUpdateNow}
>
Installieren &amp; neu starten
</button>
{#if !pendingUpdate.can_install}
{#if !pendingUpdate?.can_install}
<span class="muted">{UPDATE_BUSY_HINT}</span>
{/if}
{/if}
{#if installError}
<span class="error">{installError}</span>
{/if}
{:else}
{:else if selfUpdateCapable !== true}
<!-- Not able to self-update, or unknown (`canSelfUpdate()`
failed): never an install button, just the hint. -->
<span class="muted">
Updates gibt es unter Windows automatisch; unter Linux bitte das .deb neu installieren.
</span>