use done event to signal write success (just like in extract)

This commit is contained in:
Girish Ramakrishnan
2020-05-15 15:24:12 -07:00
parent 32f232d3c0
commit cc9b4e26b5
+7 -1
View File
@@ -394,6 +394,12 @@ function createWriteStream(destFile, encryption) {
ps.emit('error', new BoxError(BoxError.FS_ERROR, `Write error ${destFile}: ${error.message}`));
});
stream.on('finish', function () {
debug('createWriteStream: done.');
// we use a separate event because ps is a through2 stream which emits 'finish' event indicating end of inStream and not write
ps.emit('done');
});
if (encryption) {
let decrypt = new DecryptStream(encryption);
decrypt.on('error', function (error) {
@@ -749,7 +755,7 @@ function downloadDir(backupConfig, backupFilePath, dataLayout, progressCallback,
progressCallback({ message: `Downloading ${entry.fullPath} to ${destFilePath}` });
sourceStream.pipe(destStream, { end: true }).on('finish', closeAndRetry);
sourceStream.pipe(destStream, { end: true }).on('done', closeAndRetry);
});
}, done);
});