Skip to content

Commit

Permalink
GPII-4171: Wait for the pipe close event to consider the file downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
javihernandez committed Apr 7, 2020
1 parent f1807f8 commit 900b9dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ gpii.installer.artifact.download = function (downloadUrl, defaultOutputPath, out

fluid.log("Downloading ", downloadUrl);

req.pipe(outStream);
var pipe = req.pipe(outStream);

req.on("error", function (err) {
var err = "Couldn't download artifact, error was: " + err;
Expand All @@ -124,7 +124,11 @@ gpii.installer.artifact.download = function (downloadUrl, defaultOutputPath, out
req.on("end", function () {
outStream.close();
outStream = null;
event.fire(outputFile);
// This way we avoid the 'End-of-central-directory signature not found'
// error that sometimes we get.
pipe.on("close", function () {
event.fire(outputFile);
});
});
};

Expand Down

0 comments on commit 900b9dd

Please sign in to comment.