-
Notifications
You must be signed in to change notification settings - Fork 544
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
NSIS differential updates support #267
Conversation
The NSIS differential update support is tested with electron-builder (https://www.electron.build/) The AssetService.getHash function is rewritten to match the hash check of electron-builder: https://github.com/electron-userland/electron-builder/blob/552f1a4ed6f4bb83c3c548ed962c21142f07a9b4/packages/electron-updater/src/DownloadedUpdateHelper.ts#L161 They use base64 encoding for storing the hash (instead of hex), so now we have an extra parameter to controll the encoding. This paramter is used for calculating the hash of a .exe or .zip file. We also switch to sha512 because the sha256 check does not work correctly for the differential update support of electron-builder. Also, the latest.yml (or beta.yml / alpha.yml) now matches the .yml files that are generated by electron-builder. This is done for Windows and Mac .yml files. However, differential updates do not work for MacOS because electron-builder doesn't properly support it. For the differential updates to work, you have to upload a blockmap. So now the .blockmap files are also accepted as uploaded files.
There are some specific requirements for electron-builder to get differential updates to work.
Code looks good. Could there be an issue/conflict with pre-existing hashes? If nobody sees a concern I will approve/merge. Thanks for the PR! |
The `${os}` will expand to `win` and not `win32` (`win32` is`${platform}`)
If you use `${arch}`, Electron Release Server will automatically pick the right architecture for you. So we can just add that to the update url.
The pre-existing hashes won't change. Only new uploads will include the sha512-base64 version.
This could result in issues, but I don't know if this is also the case. I have also fixed some documentation issues. |
Sounds good. I think we can merge this then and if trouble arises adjustments could be made. Thanks again! |
NSIS differential updates support
Hello, i am using electron-react-boilerplate for my project, and it use electron-builder for the compliation it output a NSIS with his blockmap, i load it in the server and it works except for the differential download, when the application tries to updated itself it fails everytime and it output this. Cannot download differentially, fallback to full download: Error: sha512 checksum mismatch i cannot figure out a way to avoid mismatching, i think it should use sha256 as default encoding. |
@Lilleri, why do you think it should use sha256 as default encoding? I think sha512-base64 should be fully supported. Also, which version of electron-builder are you using? The latest version? |
i am using electron-builder 23.3.3, |
If I check the source code of electron-builder, it still seems that both sha512-base64 and sha256-hex is supported: https://github.com/electron-userland/electron-builder/blob/53327d51101b83641ece9f497577c3ac93d3e91d/packages/builder-util-runtime/src/httpExecutor.ts#L462 |
Hi! I still get a checksum mismatch when trying to differentially download. Do I need to tell electron-builder to look for the sha512, or have you figured out how to set the X-Checksum-Sha2 header? Best Regards! |
Hi @TokeyChan, I had a quick look at the current version of electron-builder and the code hasn't changed: https://github.com/electron-userland/electron-builder/blob/master/packages/builder-util-runtime/src/httpExecutor.ts#L440 Best of luck! |
This PR will add support for NSIS differential updates for Windows. The differential updates are tested using electron-builder.
Please read the commit body of 9a441a379648842949a6cbce7280f16633e5d588 to get an understanding of what is changed and why.
The hashing algorithm and encoding has changed from sha256-hex to sha512-base64 to match with electron-builder. I don't know if this will cause breaking changes to other update mechanisms. I tried to use sha256-hex, but it seems to be broken in electron-builder. Now it 100% matches the
.yml
files generated by electron-builder.Also, I have added documentation for using NSIS differential updates and how to configure electron-builder correctly.
Relates to the following issues: