ccloli / E-Hentai-Downloader

Download E-Hentai archive as zip file
GNU General Public License v3.0
1.82k stars 137 forks source link

Use StreamSaver.js? #226

Open zclimber opened 1 year ago

zclimber commented 1 year ago

FileSaver.js has a link to StreamSaver.js, using which should resolve RAM issues. It uses WritableStreams API that is declared supported in all major browsers, and falls back to building a blob if it is unavailable, like in FileSaver.

ccloli commented 1 year ago

For now the script doesn't have plan to download with StreamSaver.js as mentioned in https://github.com/ccloli/E-Hentai-Downloader/issues/210#issuecomment-1140222491 , since having no time or no interest to refactor the code. Besides, StreamSaver.js requires running a ServiceWorker to work, which may break E-Hentai site; or requires a cross-origin iframe to work, but for the stability concerns it may not work for everyone like some region have connection issues with these cross-origin sites.

For now, if you're using Chromium-like browser, you can enable Use File System to handle large Zip file and set it to 0 to force enable it. File System API is a bit stream-like, which can write buffers to an internal file system on-the-fly, so it should be similar to use StreamSaver.js, the only difference for user side is that it needs to write all the chunks to the file system, then gives you the file.

In the future, the script may use File System Access API instead, which implements WritableFileStream, that can write the file to the disk directly. I've use it in another script and it looks fine.