feat: allow active update downloads to be canceled
Keep the dialog cancel action available during update downloads, abort the active network stream, and surface a clean canceled state with retry support. Normalize cancellation across updater, main process, renderer, and translations with regression coverage.
This commit is contained in:
+6
-6
@@ -359,9 +359,10 @@ async function prepareUpdate(onProgress, options = {}) {
|
||||
return prepared;
|
||||
|
||||
} catch (err) {
|
||||
const failure = signal.aborted ? new Error('Update abgebrochen') : err;
|
||||
if (stagedInstallerPath) fs.rmSync(stagedInstallerPath, { force: true });
|
||||
if (onProgress) onProgress({ stage: 'error', error: err.message });
|
||||
throw err;
|
||||
if (onProgress) onProgress({ stage: signal.aborted ? 'aborted' : 'error', error: failure.message });
|
||||
throw failure;
|
||||
} finally {
|
||||
activeAbort = null;
|
||||
}
|
||||
@@ -387,10 +388,9 @@ function launchPreparedUpdate(prepared, options = {}) {
|
||||
}
|
||||
|
||||
function abortUpdate() {
|
||||
if (activeAbort) {
|
||||
activeAbort.abort();
|
||||
activeAbort = null;
|
||||
}
|
||||
if (!activeAbort) return false;
|
||||
activeAbort.abort();
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = { checkForUpdate, fetchGithubReleaseNotes, prepareUpdate, launchPreparedUpdate, abortUpdate, isNewer, resolveReleaseVersion, pickSetupAsset, parseLatestYml, createUpdateAnnouncementState };
|
||||
|
||||
Reference in New Issue
Block a user