Rewrite download code to avoid using Node APIs in the renderer #7347
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.
Rewrite download code to avoid using Node APIs in the renderer
Pull Request Type
Related issues
Description
This pull request refactors the downloading code to no longer use Node.js APIs in the renderer process. Like the screenshot code the the code path that prompts the user where to save the file each time doesn't need any Node.js APIs anymore thanks to the Web File System API and writing to the default folder happens through an API call that only accepts the file name and file content (the default folder path is read in the main process).
Please note that improving the in-app downloader was a non-goal of this pull request, I just wanted to remove the usage of the Node.js APIs to get us one step closer to turning off
nodeIntegrationin the renderer processes. The downloader is still slow and for the default path approach it still buffers the entire downloaded file in memory, writing everything to the file in one go at the end. The prompting for a file path approach does now stream directly to the file though, thanks to the use of the Web File System API.Testing
Try downloading subtitles and audio tracks on this short video with both the prompting for the file path and downloading to the default folder options: https://youtu.be/jNQXAC9IVRw
You are of course welcome to test with longer videos or downloading the video streams but as the downloader is very slow downloading that much data is going to take a long time and you just need to check that these changes didn't break anything.
Desktop