storage: done events must be called next tick
It seems that listDir() returns synchronously (!), not sure how. This results in the done event getting called with an error but the EE event handlers are not setup yet.
This commit is contained in:
@@ -324,7 +324,7 @@ function copy(apiConfig, oldFilePath, newFilePath) {
|
||||
}, function (error) {
|
||||
events.emit('progress', `Copied ${total} files with error: ${error}`);
|
||||
|
||||
events.emit('done', error);
|
||||
process.nextTick(() => events.emit('done', error));
|
||||
});
|
||||
|
||||
return events;
|
||||
@@ -364,7 +364,7 @@ function removeDir(apiConfig, pathPrefix) {
|
||||
var total = 0;
|
||||
|
||||
getS3Config(apiConfig, function (error, credentials) {
|
||||
if (error) events.emit('done', error);
|
||||
if (error) return process.nextTick(() => events.emit('done', error));
|
||||
|
||||
var s3 = new AWS.S3(credentials);
|
||||
|
||||
@@ -397,7 +397,7 @@ function removeDir(apiConfig, pathPrefix) {
|
||||
}, function (error) {
|
||||
events.emit('progress', `Removed ${total} files`);
|
||||
|
||||
events.emit('done', error);
|
||||
process.nextTick(() => events.emit('done', error));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user