Skip to content

Commit

Permalink
fixing rejection error
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Jul 27, 2020
1 parent 69d8d43 commit 1ebc8c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ module.exports = async function (uri) {
return Promise.resolve();
}
} catch (err) {
this.log('error', ['storage.delete', JSON.stringify({ uri, message: err.message, stack: err.stack })]);
return Promise.reject(err);
}
};
3 changes: 1 addition & 2 deletions src/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const awsListObjects = async (that, bucket, path, next) => {
} catch (err) {
this.error('error', [
'storage.list.awsListObjects',
JSON.stringify({ bucket, path, next, message: err.message, stack: err.stack })
JSON.stringify({ bucket, path, next, message: err.message, stack: err.stack }),
]);
return Promise.reject(err);
}
Expand Down Expand Up @@ -95,7 +95,6 @@ module.exports = async function (uri) {
return Promise.resolve(file);
}
} catch (err) {
this.log('error', ['storage.list', JSON.stringify({ uri, message: err.message, stack: err.stack })]);
return Promise.reject(err);
}
};
1 change: 0 additions & 1 deletion src/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module.exports = async function (uri) {
return Promise.resolve(file);
}
} catch (err) {
this.log('error', ['storage.load', JSON.stringify({ uri, message: err.message, stack: err.stack })]);
return Promise.reject(err);
}
};
38 changes: 18 additions & 20 deletions src/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ module.exports = async function (sourceUri, destinationUri, keepOriginal) {
this.log('log', ['storage.move.aws2aws copying >', sourceUri, destinationUri]);

// copy file
await this.sdk.s3.copyObject({
Bucket: bucket,
Key: path,
CopySource: sourceUri.replace('s3://', '/'),
}).promise();
await this.sdk.s3
.copyObject({
Bucket: bucket,
Key: path,
CopySource: sourceUri.replace('s3://', '/'),
})
.promise();

// move file within gcs
if (keepOriginal != true) {
Expand All @@ -75,10 +77,12 @@ module.exports = async function (sourceUri, destinationUri, keepOriginal) {
path = structure.join('/');

// move file
await this.sdk.s3.deleteObject({
Bucket: bucket,
Key: path,
}).promise();
await this.sdk.s3
.deleteObject({
Bucket: bucket,
Key: path,
})
.promise();
}

// return ok
Expand All @@ -97,23 +101,17 @@ module.exports = async function (sourceUri, destinationUri, keepOriginal) {
if (keepOriginal != true) {
await storage.delete(sourceUri);
} else {
this.log('log', ['storage.move.any2any not deleting sourceUri >', keepOriginal, sourceUri]);
this.log('log', [
'storage.move.any2any not deleting sourceUri >',
keepOriginal,
sourceUri,
]);
}

// return ok
return Promise.resolve();
}
} catch (err) {
this.log('error', [
'storage.move',
JSON.stringify({
sourceUri,
destinationUri,
keepOriginal,
message: err.message,
stack: err.stack,
}),
]);
return Promise.reject(err);
}
};
7 changes: 3 additions & 4 deletions src/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,17 @@ module.exports = async function (uri, buffer) {
return Promise.resolve();
} else {
// local file

// log progress
this.log('log', ['storage.save.local >', uri]);

// save file
let file = await saveLocalFile(this, uri, buffer);

// return ok
return Promise.resolve(file);
}
} catch (err) {
this.log('error', ['storage.save', JSON.stringify({ uri, message: err.message, stack: err.stack })]);
return Promise.reject(err);
}
};

0 comments on commit 1ebc8c2

Please sign in to comment.