Skip to content

Commit

Permalink
fix: Allow disabling of webinstaller files to avoid confusion with ac…
Browse files Browse the repository at this point in the history
…tual installers (#6575)

Co-authored-by: Guillermo Vaya <guivaya@gmail.com>
  • Loading branch information
devinbinnie and Willyfrog committed Jan 25, 2022
1 parent 59b6bec commit 5e381c5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-elephants-sing.md
@@ -0,0 +1,5 @@
---
"electron-updater": major
---

fix: Allow disabling of webinstaller files to avoid confusion with actual installers
13 changes: 13 additions & 0 deletions packages/electron-updater/src/AppUpdater.ts
Expand Up @@ -51,6 +51,17 @@ export abstract class AppUpdater extends EventEmitter {
*/
allowDowngrade = false

/**
* Web installer files might not have signature verification, this switch prevents to load them unless it is needed.
*
* Currently false to prevent breaking the current API, but it should be changed to default true at some point that
* breaking changes are allowed.
*
* @default false
*/

disableWebInstaller = false

/**
* The current application version.
*/
Expand Down Expand Up @@ -443,6 +454,7 @@ export abstract class AppUpdater extends EventEmitter {
updateInfoAndProvider,
requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),
cancellationToken,
disableWebInstaller: this.disableWebInstaller,
}).catch(e => {
throw errorHandler(e)
})
Expand Down Expand Up @@ -644,6 +656,7 @@ export interface DownloadUpdateOptions {
readonly updateInfoAndProvider: UpdateInfoAndProvider
readonly requestHeaders: OutgoingHttpHeaders
readonly cancellationToken: CancellationToken
readonly disableWebInstaller?: boolean
}

function hasPrereleaseComponents(version: SemVer) {
Expand Down
11 changes: 11 additions & 0 deletions packages/electron-updater/src/NsisUpdater.ts
Expand Up @@ -31,6 +31,17 @@ export class NsisUpdater extends BaseUpdater {
task: async (destinationFile, downloadOptions, packageFile, removeTempDirIfAny) => {
const packageInfo = fileInfo.packageInfo
const isWebInstaller = packageInfo != null && packageFile != null
if (isWebInstaller && downloadUpdateOptions.disableWebInstaller) {
throw newError(
`Unable to download new version ${downloadUpdateOptions.updateInfoAndProvider.info.version}. Web Installers are disabled`,
"ERR_UPDATER_WEB_INSTALLER_DISABLED"
)
}
if (!isWebInstaller && !downloadUpdateOptions.disableWebInstaller) {
this._logger.warn(
"disableWebInstaller is set to false, you should set it to true if you do not plan on using a web installer. This will default to true in a future version."
)
}
if (isWebInstaller || (await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider))) {
await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)
}
Expand Down

0 comments on commit 5e381c5

Please sign in to comment.