s3: add progress detail
this is a bit of a hack and we should add another way to set the progress (maybe via backups.setProgress or via a progress callback). this is because some methods like removeDir can be called from backuptask and from box code.
This commit is contained in:
@@ -29,6 +29,7 @@ var assert = require('assert'),
|
||||
mkdirp = require('mkdirp'),
|
||||
PassThrough = require('stream').PassThrough,
|
||||
path = require('path'),
|
||||
progress = require('../progress.js'),
|
||||
S3BlockReadStream = require('s3-block-read-stream'),
|
||||
superagent = require('superagent');
|
||||
|
||||
@@ -203,6 +204,7 @@ function downloadDir(apiConfig, backupFilePath, destDir, callback) {
|
||||
|
||||
listDir(apiConfig, backupFilePath, { batchSize: 1 }, function downloadFile(s3, content, iteratorCallback) {
|
||||
var relativePath = path.relative(backupFilePath, content.Key);
|
||||
|
||||
mkdirp(path.dirname(path.join(destDir, relativePath)), function (error) {
|
||||
if (error) return iteratorCallback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
|
||||
|
||||
@@ -240,6 +242,8 @@ function copy(apiConfig, oldFilePath, newFilePath, callback) {
|
||||
CopySource: path.join(apiConfig.bucket, content.Key)
|
||||
};
|
||||
|
||||
progress.setDetail(progress.BACKUP, 'Copying ' + content.Key.slice(oldFilePath.length+1));
|
||||
|
||||
s3.copyObject(copyParams, function (error) {
|
||||
if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, 'Old backup not found'));
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user