Make copy() return event emitter

This way the storage logic does not need to rely on progress
This commit is contained in:
Girish Ramakrishnan
2017-10-04 11:00:30 -07:00
parent 38331e71e2
commit d70ff7cd5b
7 changed files with 49 additions and 30 deletions

View File

@@ -112,7 +112,8 @@ describe('Storage', function () {
var sourceFile = gTmpFolder + '/uploadtest/test.txt'; // keep the test within save device
var destFile = gTmpFolder + '/uploadtest/test-hardlink.txt';
filesystem.copy(gBackupConfig, sourceFile, destFile, function (error) {
var events = filesystem.copy(gBackupConfig, sourceFile, destFile);
events.on('done', function (error) {
expect(error).to.be(null);
expect(fs.statSync(destFile).nlink).to.be(2); // created a hardlink
done();
@@ -169,7 +170,8 @@ describe('Storage', function () {
});
it('can copy', function (done) {
noop.copy(gBackupConfig, 'sourceFile', 'destFile', function (error) {
var events = noop.copy(gBackupConfig, 'sourceFile', 'destFile');
events.on('done', function (error) {
expect(error).to.be(null);
done();
});
@@ -256,7 +258,8 @@ describe('Storage', function () {
var sourceKey = 'uploadtest';
s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy', function (error) {
var events = s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy');
events.on('done', function (error) {
var sourceFile = path.join(__dirname, 'storage/data/test.txt');
expect(error).to.be(null);
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);