@@ -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 ( ) ;
@@ -131,9 +130,8 @@ module.exports = CoreObject.extend({
131130 params . ServerSideEncryption = serverSideEncryption ;
132131 }
133132
134- return this . fetchRevisions ( options ) . then ( function ( revisions ) {
135- var found = revisions . map ( function ( element ) { return element . revision ; } ) . indexOf ( options . revisionKey ) ;
136- if ( found >= 0 ) {
133+ return this . findRevision ( options ) . then ( function ( found ) {
134+ if ( found !== undefined ) {
137135 return copyObject ( params ) . then ( function ( ) {
138136 plugin . log ( '✔ ' + revisionKey + " => " + indexKey ) ;
139137 } ) ;
@@ -143,6 +141,17 @@ module.exports = CoreObject.extend({
143141 } ) ;
144142 } ,
145143
144+ findRevision : function ( options ) {
145+ var client = this . _client ;
146+ var listObjects = RSVP . denodeify ( client . listObjects . bind ( client ) ) ;
147+ var bucket = options . bucket ;
148+ var prefix = options . prefix ;
149+ var revisionPrefix = joinUriSegments ( prefix , options . filePattern + ":" + options . revisionKey ) ;
150+
151+ return listObjects ( { Bucket : bucket , Prefix : revisionPrefix } )
152+ . then ( ( response ) => response . Contents . find ( ( element ) => element . Key === revisionPrefix ) ) ;
153+ } ,
154+
146155 fetchRevisions : function ( options ) {
147156 var client = this . _client ;
148157 var bucket = options . bucket ;
0 commit comments