Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for differential zip updates on macOS #7709

Merged
merged 19 commits into from
Feb 27, 2024

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Aug 3, 2023

Fix #7547

@changeset-bot
Copy link

changeset-bot bot commented Aug 3, 2023

🦋 Changeset detected

Latest commit: cb40ebe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
electron-updater Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Aug 3, 2023

Deploy Preview for car-park-attendant-cleat-11576 ready!

Name Link
🔨 Latest commit cb40ebe
🔍 Latest deploy log https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/65dcb878e1237f000724bc77
😎 Deploy Preview https://deploy-preview-7709--car-park-attendant-cleat-11576.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@beyondkmp beyondkmp changed the title Support Mac difference download feat: add support Mac difference download Aug 3, 2023
@beyondkmp beyondkmp changed the title feat: add support Mac difference download feat: add support differential update on macOS Aug 3, 2023
@github-actions github-actions bot removed the windows label Aug 3, 2023
@beyondkmp beyondkmp changed the title feat: add support differential update on macOS Draft: feat: add support differential update on macOS Aug 3, 2023
@beyondkmp beyondkmp changed the title Draft: feat: add support differential update on macOS feat: add support differential update on macOS Aug 3, 2023
@mmaietta
Copy link
Collaborator

mmaietta commented Aug 5, 2023

Thanks for contributing!

Please see build error:

Module '"builder-util-runtime"' has no exported member 'CURRENT_MAC_APP_ZIP_FILE_NAME'.

@beyondkmp
Copy link
Collaborator Author

Thanks for contributing!

Please see build error:

Module '"builder-util-runtime"' has no exported member 'CURRENT_MAC_APP_ZIP_FILE_NAME'.

Fixed

@beyondkmp
Copy link
Collaborator Author

@mmaietta I will fix these unit tests, but it might take some time as I've been quite busy lately.

@mmaietta
Copy link
Collaborator

Sounds great @beyondkmp! Really appreciate you picking this up!

Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Nov 11, 2023
@mmaietta
Copy link
Collaborator

mmaietta commented Feb 24, 2024

Alright, I got the differential test suite fixed. It was an issue with circular references/imports and then I had to fix the windows+linux tests themselves w/ a small refactor. Just updated your PR with latest master

@mmaietta mmaietta changed the title feat: add support differential update on macOS feat: add support for differential zip updates on macOS Feb 24, 2024
@mmaietta
Copy link
Collaborator

Tests are passing but there's an error when I tested it out using a localhost server

[error] Cannot download differentially, fallback to full download: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:1039:7)
    at MacUpdater.differentialDownloadInstaller (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:586:31)
    at Object.task (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/MacUpdater.js:83:32)
    at MacUpdater.executeDownload (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:548:31)

@beyondkmp
Copy link
Collaborator Author

Tests are passing but there's an error when I tested it out using a localhost server

[error] Cannot download differentially, fallback to full download: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:1039:7)
    at MacUpdater.differentialDownloadInstaller (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:586:31)
    at Object.task (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/MacUpdater.js:83:32)
    at MacUpdater.executeDownload (/electron-builder-test/dist/electron-quick-start-typescript.app/Contents/Resources/app.asar/node_modules/electron-updater/out/AppUpdater.js:548:31)

I have moved CURRENT_MAC_APP_ZIP_FILE_NAME into MacUpdater.ts to fix it. You can try it in latest commit.

@mmaietta
Copy link
Collaborator

Testing this further, I can't get the differential download to work correctly, I keep receiving a checksum mismatch for some reason.

Cannot download differentially, fallback to full download: Error: sha512 checksum mismatch, expected TuNB4sWHMz/8a8H+g32IlXpet9aFS1SlDAhbkWy9QuSkPlPW8+1TgsNdh8jLo+DVEfUtjBvnoJbw8dr6HMEHcA==, got vhSVmETkWgobSMa3biddjNeo20QePxDgG2FTRAqvWUkHyrU2T+pGa4KgyQoOpxF31qSpOuD2ils900HYhFFVCg==

Are you able to get the differential download working? You can use a minio server locally to set up a localhost "s3" config, on MacOS, it's as easy as using brew install minio + the setup with the instructions below
https://www.electron.build/tutorials/test-update-on-s3-locally

@beyondkmp
Copy link
Collaborator Author

@mmaietta I can. Here's logs

2024-02-26T14:15:25.599+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: /4cFBaLj9grwTU0jv6OTGeJe duplicated in blockmap (same size), it doesn't lead to broken differential downloader, just corresponding block will be skipped)
2024-02-26T14:15:25.599+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: o0MSgzsL7wr02KddiDQOx64N duplicated in blockmap (same size), it doesn't lead to broken differential downloader, just corresponding block will be skipped)
2024-02-26T14:15:25.600+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: 15e/AHUeiZeB/8kP4WUstznD duplicated in blockmap (same size), it doesn't lead to broken differential downloader, just corresponding block will be skipped)
2024-02-26T14:15:25.600+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: gRHNaDm9LqR4/gc0CPRVe+Iv duplicated in blockmap (same size), it doesn't lead to broken differential downloader, just corresponding block will be skipped)
2024-02-26T14:15:25.601+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: /lOV1D7Lk3AdOYM457wkehlD duplicated in blockmap (same size), it doesn't lead to broken differential downloader, just corresponding block will be skipped)
2024-02-26T14:15:25.608+0800 INFO: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: File has 2371 changed blocks
2024-02-26T14:15:25.640+0800 DEBUG: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: {"truncation":"[\n  {\n    \"kind\": 1,\n    \"start\": 0,\n    \"end\": 32768\n  },\n  {\n    \"kind\": 0,\n    \"start\": 32768,\n    \"end\": 60026699\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60026699,\n    \"end\": 60054775\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60054775,\n    \"end\": 60066471\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60066471,\n    \"end\": 60153556\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60153556,\n    \"end\": 60164856\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60164856,\n    \"end\": 60250146\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60250146,\n    \"end\": 60265982\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60265982,\n    \"end\": 60332341\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60332341,\n    \"end\": 60341828\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60341828,\n    \"end\": 60429566\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60429566,\n    \"end\": 60439715\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60439715,\n    \"end\": 60577813\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60577813,\n    \"end\": 60591229\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60591229,\n    \"end\": 60715152\n  },\n  {\n    \"kind\": 0,\n    \"start\": 60715152,\n    \"end\": 60732527\n  },\n  {\n    \"kind\": 1,\n    \"start\": 60732527,\n    \"end\": 61051932\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61051932,\n    \"end\": 61063648\n  },\n  {\n    \"kind\": 1,\n    \"start\": 61063648,\n    \"end\": 61072282\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61072282,\n    \"end\": 61082528\n  },\n  {\n    \"kind\": 1,\n    \"start\": 61082528,\n    \"end\": 61092268\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61092268,\n    \"end\": 61101250\n  },\n  {\n    \"kind\": 1,\n    \"start\": 61101250,\n    \"end\": 61165773\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61165777,\n    \"end\": 61602555\n  },\n  {\n    \"kind\": 1,\n    \"start\": 61602551,\n    \"end\": 61646474\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61646483,\n    \"end\": 61691685\n  },\n  {\n    \"kind\": 1,\n    \"start\": 61691676,\n    \"end\": 61734449\n  },\n  {\n    \"kind\": 0,\n    \"start\": 61734448,\n    \"end\": 65104586\n  },\n  {\n    \"kind\": 1,\n    \"start\": 65104587,\n    \"end\": 65132246\n  },\n  {\n    \"kind\": 0,\n    \"start\": 65132245,\n    \"end\": 65173775\n  },\n  {\n    \"kind\": 1,\n    \"start\": 65173776,\n    \"end\": 65291050\n  },\n  {\n    \"kind\": 0,\n    \"start\": 65291048,\n    \"end\": 66289993\n  },\n  {\n    \"kind\": 1,\n    \"start\": 66289995,\n    \"end\": 66355079\n  },\n  {\n    \"kind\": 0,\n    \"start\": 66355073,\n    \"end\": 67861542\n  },\n  {\n    \"kind\": 1,\n    \"start\": 67861548,\n    \"end\": 67911805\n  },\n  {\n    \"kind\": 0,\n    \"start\": 67911793,\n    \"end\": 67983818\n  },\n  {\n    \"kind\": 1,\n    \"start\": 67983830,\n    \"end\": 68016598\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68016586,\n    \"end\": 68134804\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68134816,\n    \"end\": 68167349\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68167337,\n    \"end\": 68272040\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68272052,\n    \"end\": 68304820\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68304808,\n    \"end\": 68398862\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68398874,\n    \"end\": 68409099\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68409087,\n    \"end\": 68535215\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68535227,\n    \"end\": 68550445\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68550433,\n    \"end\": 68643985\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68643997,\n    \"end\": 68674273\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68674261,\n    \"end\": 68711753\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68711765,\n    \"end\": 68744533\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68744521,\n    \"end\": 68810057\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68810069,\n    \"end\": 68842837\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68842825,\n    \"end\": 68940766\n  },\n  {\n    \"kind\": 1,\n    \"start\": 68940778,\n    \"end\": 68956370\n  },\n  {\n    \"kind\": 0,\n    \"start\": 68956358,\n    \"end\": 69058342\n  },\n  {\n    \"kind\": 1,\n    \"start\": 69058354,\n    \"end\": 69073589\n  },\n  {\n    \"kind\": 0,\n    \"start\": 69073577,\n    \"end\": 69175852\n  },\n  {\n    \"kind\": 1,\n    \"start\": 69175864,\n    \"end\": 69198717\n  },\n  {\n    \"kind\": 0,\n    \"start\": 69198705,\n    \"end\": 69307015\n  },\n  {\n    \"kind\": 1,\n    \"start\": 69307027,\n    \"end\": 69323452\n  },\n  {\n    \"kind\": 0,\n    \"start\": 69323440,\n    \"end\": 69405"}
2024-02-26T14:15:27.276+0800 INFO: ELECTRON,[UPDATE],[UpdateController]],[ElectronUpdater]: Full: 330,805.67 KB, To download: 50,556.52 KB (15%)

The error you encountered is due to updater.zip not being the current version. The reason for this is as follows: the initial download for the update was successful, and it was copied to the cache directory. However, if you did not exit the installation of the new version, and the server subsequently updated to another version, attempting to download the incremental update would result in this error because the original updater.zip no longer matches.

PayneFuRC and others added 2 commits February 26, 2024 16:03
…t, in which case differential download cannot proceed, so we avoid a confusing error message with this check.
@mmaietta
Copy link
Collaborator

Nice work! I've added an additional check for when the update file hasn't existed yet due to app's first install/update. It also includes the override downloadUpdateOptions.disableDifferentialDownload property in case the developer has explicitly disabled it

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
}

@mmaietta
Copy link
Collaborator

Tests are passing.

@beyondkmp I think all necessary steps for implementation are complete and ready for merge. Can you please confirm when you have a chance?

@beyondkmp
Copy link
Collaborator Author

Thanks for fixing the UT, I have no issues now. You can help merge it.

@mmaietta mmaietta merged commit 79df542 into electron-userland:master Feb 27, 2024
13 checks passed
@mmaietta
Copy link
Collaborator

Thanks for your contribution!

@github-actions github-actions bot mentioned this pull request Feb 27, 2024
@ThatKawaiiSam
Copy link

Screenshot 2024-03-03 at 10 51 07 am

@mmaietta @beyondkmp I was testing this within my application this morning - seems as if the first time it can't differentially download it never actually falls back to download the full bundle which is a little concerning...

Happy to help diagnose over discord if needed (thatkawaiisam)

@mmaietta
Copy link
Collaborator

mmaietta commented Mar 3, 2024

That's seriously concerning. Will revert this PR and debug after

mmaietta added a commit that referenced this pull request Mar 3, 2024
mmaietta added a commit that referenced this pull request Mar 3, 2024
* Revert "feat: add support for differential zip updates on macOS (#7709)"

This reverts commit 79df542.
mmaietta added a commit that referenced this pull request Mar 3, 2024
@mmaietta
Copy link
Collaborator

mmaietta commented Mar 3, 2024

Took another go and it and this should fix it: #8093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why isn't differential update supported on macOS?
5 participants