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

Downloaded files can end truncated #33

Open
manast opened this issue Nov 1, 2021 · 0 comments
Open

Downloaded files can end truncated #33

manast opened this issue Nov 1, 2021 · 0 comments

Comments

@manast
Copy link

manast commented Nov 1, 2021

The code here is incorrect since it is listening to the source stream "end" event which may trigger much sooner than the target stream has actually completed the writing to disk:

res.on ('end', function (err) {

Instead you must listen to the "finish" event on the downloadStream, to make sure the file is completely stored and closed in disk. You may have not noticed this problem since as long as the process is still alive the file will eventually complete, but if the process closes before, you end with a truncated file. Use case: "electron-simple-updater" will close after downloading the latest version of an app and most likely end with a truncated file that will end with the end-user having a broken electron app.

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

No branches or pull requests

1 participant