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

Differential downloads don't work when the blockmap HTTP response is compressed #7543

Closed
NoahAndrews opened this issue Apr 13, 2023 · 1 comment · Fixed by #7544
Closed

Comments

@NoahAndrews
Copy link
Contributor

NoahAndrews commented Apr 13, 2023

Skipping the version info and such because I can point to the problem in the source code (and I'll be submitting a pull request).

The content-length header specifies the size of the raw data in the HTTP body. If the data is uncompressed, that is the same thing as the size of the file that was downloaded. However, if compression was enabled for the response, content-length specifies the compressed size of the data.

electron-updater treats content-length as the size of the uncompressed data (node/Electron handles the decompression transparently), which is incorrect.


This code creates a result buffer based on the value of content-length

const contentLength = safeGetHeader(response, "content-length")
let position = -1
if (contentLength != null) {
const size = parseInt(contentLength, 10)
if (size > 0) {
if (size > 524288000) {
callback(new Error("Maximum allowed size is 500 MB"))
return
}
result = Buffer.alloc(size)

And this code raises an error if the size of the received data does not match the size of that result buffer

response.on("end", () => {
if (result != null && position !== -1 && position !== result.length) {
callback(new Error(`Received data length ${position} is not equal to expected ${result.length}`))

@NoahAndrews NoahAndrews changed the title Differential downloads are broken when the blockmap HTTP response is compressed Differential downloads don't work when the blockmap HTTP response is compressed Apr 13, 2023
@NoahAndrews
Copy link
Contributor Author

NoahAndrews commented Apr 13, 2023

I accidentally submitted this sooner than I meant to. The issue description has been updated.

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

Successfully merging a pull request may close this issue.

1 participant