Skip to content

Commit 35a2e8f

Browse files
authored
Merge pull request #123 from CrowdStrike/optimise-deploy-with-overwrite
fix: Optimise upload when `allowOverwrite` is true
2 parents 0b63c6f + d91ed0f commit 35a2e8f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/s3.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module.exports = CoreObject.extend({
6262
var isGzipped = gzippedFilePaths.indexOf(options.filePattern) !== -1;
6363
var isBrotliCompressed = brotliCompressedFilePaths.indexOf(options.filePattern) !== -1;
6464
var serverSideEncryption = options.serverSideEncryption;
65+
var checkForOverwrite = RSVP.resolve();
6566

6667
var params = {
6768
Bucket: bucket,
@@ -83,13 +84,17 @@ module.exports = CoreObject.extend({
8384
params.ContentEncoding = 'br';
8485
}
8586

86-
return this.findRevision(options)
87-
.then(function(found) {
88-
if (found !== undefined && !allowOverwrite) {
89-
return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
90-
}
91-
return RSVP.resolve();
92-
})
87+
if (!allowOverwrite) {
88+
checkForOverwrite = this.findRevision(options)
89+
.then(function(found) {
90+
if (found !== undefined) {
91+
return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
92+
}
93+
return RSVP.resolve();
94+
})
95+
}
96+
97+
return checkForOverwrite
9398
.then(readFile.bind(this, options.filePath))
9499
.then(function(fileContents) {
95100
params.Body = fileContents;

0 commit comments

Comments
 (0)