Skip to content

Commit

Permalink
Merge pull request #123 from CrowdStrike/optimise-deploy-with-overwrite
Browse files Browse the repository at this point in the history
fix: Optimise upload when `allowOverwrite` is true
  • Loading branch information
lukemelia authored Jul 10, 2022
2 parents 0b63c6f + d91ed0f commit 35a2e8f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = CoreObject.extend({
var isGzipped = gzippedFilePaths.indexOf(options.filePattern) !== -1;
var isBrotliCompressed = brotliCompressedFilePaths.indexOf(options.filePattern) !== -1;
var serverSideEncryption = options.serverSideEncryption;
var checkForOverwrite = RSVP.resolve();

var params = {
Bucket: bucket,
Expand All @@ -83,13 +84,17 @@ module.exports = CoreObject.extend({
params.ContentEncoding = 'br';
}

return this.findRevision(options)
.then(function(found) {
if (found !== undefined && !allowOverwrite) {
return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
}
return RSVP.resolve();
})
if (!allowOverwrite) {
checkForOverwrite = this.findRevision(options)
.then(function(found) {
if (found !== undefined) {
return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
}
return RSVP.resolve();
})
}

return checkForOverwrite
.then(readFile.bind(this, options.filePath))
.then(function(fileContents) {
params.Body = fileContents;
Expand Down

0 comments on commit 35a2e8f

Please sign in to comment.