fs: emit progress messages for copy and removeDir
This commit is contained in:
@@ -113,13 +113,13 @@ function copy(apiConfig, oldFilePath, newFilePath) {
|
||||
assert.strictEqual(typeof oldFilePath, 'string');
|
||||
assert.strictEqual(typeof newFilePath, 'string');
|
||||
|
||||
debug('copy: %s -> %s', oldFilePath, newFilePath);
|
||||
|
||||
var events = new EventEmitter();
|
||||
|
||||
mkdirp(path.dirname(newFilePath), function (error) {
|
||||
if (error) return events.emit('done', new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
|
||||
|
||||
events.emit('progress', `Copying ${oldFilePath} to ${newFilePath}`);
|
||||
|
||||
// this will hardlink backups saving space
|
||||
var cpOptions = apiConfig.noHardlinks ? '-a' : '-al';
|
||||
shell.spawn('copy', '/bin/cp', [ cpOptions, oldFilePath, newFilePath ], { }, function (error) {
|
||||
@@ -155,7 +155,7 @@ function removeDir(apiConfig, pathPrefix) {
|
||||
|
||||
var events = new EventEmitter();
|
||||
|
||||
events.emit('progress', `removeDir: ${pathPrefix}`);
|
||||
process.nextTick(() => events.emit('progress', `Removing directory ${pathPrefix}`));
|
||||
|
||||
shell.spawn('removeDir', '/bin/rm', [ '-rf', pathPrefix ], { }, function (error) {
|
||||
if (error) return events.emit('done', new BackupsError(BackupsError.EXTERNAL_ERROR, error.message));
|
||||
|
||||
Reference in New Issue
Block a user