Add support for > 2GB download and extraction#2190
Open
ethangreen-dev wants to merge 2 commits into
Open
Conversation
adm-zip loads the entire archive into a single Buffer via fs.readFileSync, which throws ERR_FS_FILE_TOO_LARGE for files over 2GB. Swap the zip:extractAllTo handler to extract-zip, which streams each entry through yauzl and supports ZIP64. The remaining adm-zip uses operate on small manifest and profile zips and are left untouched.
The renderer downloaded mods with axios responseType 'arraybuffer', which buffered the whole file into a single ArrayBuffer (null past ~2GB in the XHR adapter) and then wrote it to disk in one fs.writeFile (capped at 2147483647 bytes). Both failed for mods larger than 2GB. Move the download to the main process: a new node:net:download IPC streams the response straight to a file and reports progress back over webContents.send. It uses Electron's net module so downloads stay on Chromium's network stack, honouring the same proxy and TLS settings as the rest of the app. Partial files are removed on failure so a stalled download isn't mistaken for a completed one.
ebkr
reviewed
Jun 8, 2026
ebkr
left a comment
Owner
There was a problem hiding this comment.
Added some comments, will test once other work is merged and any conflicts are resolved
|
|
||
| function downloadToFile(url: string, destPath: string, onProgress: (loaded: number) => void): Promise<void> { | ||
| return new Promise((resolve, reject) => { | ||
| const writeStream = fs.createWriteStream(destPath); |
Owner
There was a problem hiding this comment.
How well does this handle two of the same dependency being downloaded at the same time, assuming a flow could be that someone invokes a download, closes the modal, goes to another mod and downloads that too.
It might be worth assigning these with temporary IDs, and then rename upon completion.
| resolve(); | ||
| }); | ||
| // Electron's IncomingMessage is a Readable at runtime but isn't typed as one. | ||
| (response as unknown as Readable).pipe(writeStream); |
Owner
There was a problem hiding this comment.
Is this synchronous? Is it not callback defined and then needs some .on handlers?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a simple-as-possible implementation which adds support for package download and extract for archives that are greater than 2GB in size. This is achieved using two mechanisms:
To keep in mind:
And, to test it: