From 43950014b259f176f28b132a8f185dd71d89867c Mon Sep 17 00:00:00 2001 From: Sucukdeluxe Date: Sun, 1 Mar 2026 15:51:13 +0100 Subject: [PATCH] Retry updater candidates after hash mismatch --- src/main/update.ts | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/update.ts b/src/main/update.ts index 84a3598..1a7464b 100644 --- a/src/main/update.ts +++ b/src/main/update.ts @@ -941,18 +941,41 @@ export async function installLatestUpdate( if (updateAbortController.signal.aborted) { throw new Error("aborted:update_shutdown"); } - await downloadFromCandidates(candidates, targetPath, onProgress); - if (updateAbortController.signal.aborted) { - throw new Error("aborted:update_shutdown"); + let verified = false; + let lastVerifyError: unknown = null; + for (let index = 0; index < candidates.length; index += 1) { + const candidate = candidates[index]; + try { + await downloadWithRetries(candidate, targetPath, onProgress); + if (updateAbortController.signal.aborted) { + throw new Error("aborted:update_shutdown"); + } + safeEmitProgress(onProgress, { + stage: "verifying", + percent: 100, + downloadedBytes: 0, + totalBytes: null, + message: `Prüfe Installer-Integrität (${index + 1}/${candidates.length})` + }); + await verifyDownloadedInstaller(targetPath, String(effectiveCheck.setupAssetDigest || "")); + verified = true; + break; + } catch (error) { + lastVerifyError = error; + try { + await fs.promises.rm(targetPath, { force: true }); + } catch { + // ignore + } + if (index >= candidates.length - 1) { + throw error; + } + logger.warn(`Update-Kandidat ${index + 1}/${candidates.length} verworfen: ${compactErrorText(error)}`); + } + } + if (!verified) { + throw lastVerifyError || new Error("Update-Download fehlgeschlagen"); } - safeEmitProgress(onProgress, { - stage: "verifying", - percent: 100, - downloadedBytes: 0, - totalBytes: null, - message: "Prüfe Installer-Integrität" - }); - await verifyDownloadedInstaller(targetPath, String(effectiveCheck.setupAssetDigest || "")); safeEmitProgress(onProgress, { stage: "launching", percent: 100,