Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
s3Client.upload(params, function(err, data) {
debug('Object store upload done');
if (err) {
debug(err);
reject(new VError(err, 'Object store upload failed'));
return;
}
debug('Object store upload succeeded');
debug(data);
resolve();
}).httpUploadProgress = (progress) => {
debug(`Object store upload progress: ${progress}`);
};
debug(`Starting streaming data from ${s(sourceUrl)}`);
couchbackup.backup(
sourceUrl,
streamToUpload,
(err, obj) => {
if (err) {
debug(err);
reject(new VError(err, 'CouchBackup failed with an error'));
return;
}
debug(`Download from ${s(sourceUrl)} complete.`);
streamToUpload.end(); // must call end() to complete upload.
// resolve() is called by the upload
}
);
});
}
return new Promise((resolve, reject) => {
couchbackup.backup(
sourceUrl,
fs.createWriteStream(backupTmpFilePath),
(err) => {
if (err) {
return reject(new VError(err, 'CouchBackup process failed'));
}
debug('couchbackup to file done; uploading to S3');
resolve('creating backup file complete');
}
);
});
}