Skip to content

Commit

Permalink
feat(nsis): add option to disable differential download (#7950)
Browse files Browse the repository at this point in the history
  • Loading branch information
bronsonmock committed Jan 5, 2024
1 parent 9335c59 commit 03c9451
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-icons-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

feat(nsis): add option to disable differential download
3 changes: 3 additions & 0 deletions docs/api/electron-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,9 @@ return path.join(target.outDir, <code>__${target.name}-${getArtifactArchName(arc
<p>Currently false to prevent breaking the current API, but it should be changed to default true at some point that breaking changes are allowed.</p>
</li>
<li>
<p><code id="AppUpdater-disableDifferentialDownload">disableDifferentialDownload</code> = <code>false</code> Boolean - <em>NSIS only</em> Disable differential downloads and always perform full download of installer.</p>
</li>
<li>
<p><code id="AppUpdater-forceDevUpdateConfig">forceDevUpdateConfig</code> = <code>false</code> Boolean - Allows developer to force the updater to work in “dev” mode, looking for “dev-app-update.yml” instead of “app-update.yml” Dev: <code>path.join(this.app.getAppPath(), &quot;dev-app-update.yml&quot;)</code> Prod: <code>path.join(process.resourcesPath!, &quot;app-update.yml&quot;)</code></p>
</li>
<li>
Expand Down
9 changes: 9 additions & 0 deletions packages/electron-updater/src/AppUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
*/
disableWebInstaller = false

/**
* *NSIS only* Disable differential downloads and always perform full download of installer.
*
* @default false
*/
disableDifferentialDownload = false

/**
* Allows developer to force the updater to work in "dev" mode, looking for "dev-app-update.yml" instead of "app-update.yml"
* Dev: `path.join(this.app.getAppPath(), "dev-app-update.yml")`
Expand Down Expand Up @@ -493,6 +500,7 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter
requestHeaders: this.computeRequestHeaders(updateInfoAndProvider.provider),
cancellationToken,
disableWebInstaller: this.disableWebInstaller,
disableDifferentialDownload: this.disableDifferentialDownload,
}).catch((e: any) => {
throw errorHandler(e)
})
Expand Down Expand Up @@ -696,6 +704,7 @@ export interface DownloadUpdateOptions {
readonly requestHeaders: OutgoingHttpHeaders
readonly cancellationToken: CancellationToken
readonly disableWebInstaller?: boolean
readonly disableDifferentialDownload?: boolean
}

function hasPrereleaseComponents(version: SemVer) {
Expand Down
6 changes: 5 additions & 1 deletion packages/electron-updater/src/NsisUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export class NsisUpdater extends BaseUpdater {
"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))) {
if (
isWebInstaller ||
downloadUpdateOptions.disableDifferentialDownload ||
(await this.differentialDownloadInstaller(fileInfo, downloadUpdateOptions, destinationFile, provider))
) {
await this.httpExecutor.download(fileInfo.url, destinationFile, downloadOptions)
}

Expand Down

0 comments on commit 03c9451

Please sign in to comment.