Commit cc9b4e26 authored by Girish Ramakrishnan's avatar Girish Ramakrishnan

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

parent 32f232d3
......@@ -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
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);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment