@@ -183,8 +183,6 @@ function objectMPU(bucket, key, parts, partSize, callback) {
183183 return async . waterfall ( [
184184 next => s3Client . send ( new CreateMultipartUploadCommand ( initiateMPUParams ) )
185185 . then ( data => {
186- // eslint-disable-next-line no-console
187- console . log ( 'Initiated multipart upload:' , data ) ;
188186 uploadId = data . UploadId ;
189187 return next ( ) ;
190188 } )
@@ -199,9 +197,7 @@ function objectMPU(bucket, key, parts, partSize, callback) {
199197 Body : Buffer . alloc ( partSize ) ,
200198 } ;
201199 return s3Client . send ( new UploadPartCommand ( uploadPartParams ) )
202- . then ( data => {
203- return callback ( null , data . ETag ) ;
204- } )
200+ . then ( data => callback ( null , data . ETag ) )
205201 . catch ( callback ) ;
206202 } , ( err , results ) => {
207203 if ( err ) {
@@ -223,7 +219,7 @@ function objectMPU(bucket, key, parts, partSize, callback) {
223219 UploadId : uploadId ,
224220 } ;
225221 return s3Client . send ( new CompleteMultipartUploadCommand ( params ) )
226- . then ( ( ) => next ( ) )
222+ . then ( data => next ( null , data ) )
227223 . catch ( next ) ;
228224 } ,
229225 ] , err => {
@@ -235,6 +231,12 @@ function objectMPU(bucket, key, parts, partSize, callback) {
235231}
236232
237233function abortMPU ( bucket , key , uploadId , size , callback ) {
234+ // Handle case where uploadId is null/undefined
235+ if ( ! uploadId ) {
236+ console . log ( 'Warning: Attempted to abort MPU with null uploadId' ) ;
237+ return callback ( ) ;
238+ }
239+
238240 return s3Client . send ( new AbortMultipartUploadCommand ( {
239241 Bucket : bucket ,
240242 Key : key ,
@@ -246,7 +248,14 @@ function abortMPU(bucket, key, uploadId, size, callback) {
246248 }
247249 return callback ( null , data ) ;
248250 } )
249- . catch ( err => callback ( err ) ) ;
251+ . catch ( err => {
252+ // Don't fail the test if the abort fails due to the MPU not existing
253+ if ( err . name === 'NoSuchUpload' ) {
254+ console . log ( 'MPU already cleaned up or does not exist' ) ;
255+ return callback ( ) ;
256+ }
257+ return callback ( err ) ;
258+ } ) ;
250259}
251260
252261function uploadPartCopy ( bucket , key , partNumber , partSize , sleepDuration , keyToCopy , callback ) {
@@ -489,6 +498,8 @@ function multiObjectDelete(bucket, keys, size, callback) {
489498 next => sendRequest ( putQuotaVerb , '127.0.0.1:8000' , `/${ bucket } /?quota=true` ,
490499 JSON . stringify ( quota ) , config ) . then ( ( ) => next ( ) ) . catch ( err => next ( err ) ) ,
491500 next => objectMPU ( bucket , key , parts , partSize , ( err , _uploadId ) => {
501+ // eslint-disable-next-line no-console
502+ console . log ( 'objectMPU' , _uploadId ) ;
492503 uploadId = _uploadId ;
493504 try {
494505 assert . strictEqual ( err . name , 'QuotaExceeded' ) ;
@@ -971,9 +982,7 @@ function multiObjectDelete(bucket, keys, size, callback) {
971982 } catch ( assertError ) {
972983 return next ( assertError ) ;
973984 }
974- } ) ,
975- // Simulate the real restore
976- next => putObjectWithCustomHeader ( bucket , key , size , vID , err => {
985+ , err => {
977986 assert . ifError ( err ) ;
978987 return next ( ) ;
979988 } ) ,
0 commit comments