Skip to content

Commit

Permalink
Reimplements: #7709
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Mar 3, 2024
1 parent cb335ec commit 67cfe23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-tigers-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix: Reimplements: #7709
17 changes: 7 additions & 10 deletions packages/electron-updater/src/MacUpdater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AllPublishOptions, newError, safeStringifyJson } from "builder-util-runtime"
import { pathExistsSync, stat } from "fs-extra"
import { stat } from "fs-extra"
import { createReadStream, copyFileSync } from "fs"
import * as path from "path"
import { createServer, IncomingMessage, Server, ServerResponse } from "http"
Expand Down Expand Up @@ -101,17 +101,14 @@ export class MacUpdater extends AppUpdater {
downloadUpdateOptions,
task: async (destinationFile, downloadOptions) => {
const cachedFile = path.join(this.downloadedUpdateHelper!.cacheDir, CURRENT_MAC_APP_ZIP_FILE_NAME)
const canDifferentialDownload = () => {
if (!pathExistsSync(cachedFile)) {
log.info("Unable to locate previous update.zip for differential download (is this first install?), falling back to full download")
return false
}
return !downloadUpdateOptions.disableDifferentialDownload
}
if (canDifferentialDownload() && (await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME))) {
if (downloadUpdateOptions.disableDifferentialDownload || (await this.differentialDownloadInstaller(zipFileInfo, downloadUpdateOptions, destinationFile, provider, CURRENT_MAC_APP_ZIP_FILE_NAME))) {
await this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)
}
copyFileSync(destinationFile, cachedFile)
try {
copyFileSync(destinationFile, cachedFile)
} catch (error: any) {
log.error(`Unable to copy file for caching: ${error.message}`)
}
},
done: event => this.updateDownloaded(zipFileInfo, event),
})
Expand Down

0 comments on commit 67cfe23

Please sign in to comment.