Skip to content

Downloaded files can end truncated #33

@manast

Description

@manast

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions