Skip to content

Commit 079ac84

Browse files
author
Kelvin Luck
committed
fix: Apply same optimisation to upload hook
We were again grabbing _every_ uploaded revision in order to be able to check if you were trying to overwrite a revision. This is slow when you have many revisions uploaded to s3. Here we prefer our new `findRevision` method which uses the `Prefix` to load information about _just_ the revision we're interested in.
1 parent b8436dc commit 079ac84

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/s3.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ module.exports = CoreObject.extend({
8383
params.ContentEncoding = 'br';
8484
}
8585

86-
return this.fetchRevisions(options)
87-
.then(function(revisions) {
88-
var found = revisions.map(function(element) { return element.revision; }).indexOf(options.revisionKey);
89-
if (found >= 0 && !allowOverwrite) {
86+
return this.findRevision(options)
87+
.then(function(found) {
88+
if (found !== undefined && !allowOverwrite) {
9089
return RSVP.reject("REVISION ALREADY UPLOADED! (set `allowOverwrite: true` if you want to support overwriting revisions)");
9190
}
9291
return RSVP.resolve();

0 commit comments

Comments
 (0)