r2modmanPlus
r2modmanPlus copied to clipboard
Add support for > 2GB download and extraction
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:
- Downloads now stream to disc in the main process. Instead of the renderer buffering the response via an ArrayBuffer (which has that 2GB limit), a new node:net:download IPC fetches the package and pipes it directly into an output stream.
- Extraction streams one entry at a time. This is done by swapping out adm-zip (which would throw ERR_FS_FILE-TOO_LARGE) for extract-zip, which extracts each entry individually and supports big boy ZIP64.
To keep in mind:
- This has been tested 6 ways to Sunday and it should work fine with TSMM, but I have yet to test it directly. I'm pretty confident though since TSMM's dotnet plugins should wholly supplant this code.
- This drags in an explicit dependency on extract-zip. Technically this package was already present as a dev dependency, so it's not anything new, but this change will now bundle it in the non-dev runtime.
And, to test it:
- Use this script to create and host a > 2GB archive:
import os, tempfile, zipfile, functools, http.server
d = tempfile.gettempdir(); z = os.path.join(d, "Big2GBTest.zip")
if not os.path.exists(z):
p = os.path.join(d, "pl.bin")
with open(p, "wb") as f: f.truncate(2306867200)
with zipfile.ZipFile(z, "w", zipfile.ZIP_STORED, allowZip64=True) as zf:
zf.writestr("manifest.json", '{"name":"Big2GBTest","version_number":"1.0.0","website_url":"","description":"","dependencies":[]}')
zf.write(p, "payload.bin")
os.remove(p)
http.server.test(HandlerClass=functools.partial(http.server.SimpleHTTPRequestHandler, directory=d), port=8080)
- Apply this patch to force r2 to download from it:
diff --git a/src/model/ThunderstoreVersion.ts b/src/model/ThunderstoreVersion.ts
index d18b3f7e..2d50fc5b 100644
--- a/src/model/ThunderstoreVersion.ts
+++ b/src/model/ThunderstoreVersion.ts
@@ -105,7 +105,7 @@ export default class ThunderstoreVersion {
}
public getDownloadUrl(): string {
- return CdnProvider.addCdnQueryParameter(this.downloadUrl);
+ return "http://localhost:8080/Big2GBTest.zip";
}
public setDownloadUrl(url: string) {
- Download and install any package.