diff --git a/packages/electron-updater/src/NsisUpdater.ts b/packages/electron-updater/src/NsisUpdater.ts index 2a5ee34e3c5..711154cfc43 100644 --- a/packages/electron-updater/src/NsisUpdater.ts +++ b/packages/electron-updater/src/NsisUpdater.ts @@ -38,6 +38,17 @@ export class NsisUpdater extends AppUpdater { const tempFile = path.join(tempDir, fileInfo.name) try { await this.httpExecutor.download(fileInfo.url, tempFile, downloadOptions) + + const signatureVerificationStatus = await this.verifySignature(tempFile) + if (signatureVerificationStatus != null) { + try { + await remove(tempDir) + } + finally { + // noinspection ThrowInsideFinallyBlockJS + throw new Error(`New version ${this.versionInfo!.version} is not signed by the application owner: ${signatureVerificationStatus}`) + } + } } catch (e) { try { @@ -53,17 +64,6 @@ export class NsisUpdater extends AppUpdater { throw e } - const signatureVerificationStatus = await this.verifySignature(tempFile) - if (signatureVerificationStatus != null) { - try { - await remove(tempDir) - } - finally { - // noinspection ThrowInsideFinallyBlockJS - throw new Error(`New version ${this.versionInfo!.version} is not signed by the application owner: ${signatureVerificationStatus}`) - } - } - this._logger.info(`New version ${this.versionInfo!.version} has been downloaded to ${tempFile}`) this.setupPath = tempFile this.addQuitHandler()