@@ -103,6 +103,7 @@ function _storeNullVersionMD(bucketName, objKey, nullVersionId, objMD, log, cb)
103103 log . debug ( 'error from metadata storing null version as new version' ,
104104 { error : err } ) ;
105105 }
106+
106107 cb ( err ) ;
107108 } ) ;
108109}
@@ -252,6 +253,7 @@ function processVersioningState(mst, vstat, nullVersionCompatMode) {
252253 }
253254 return { options, nullVersionId } ;
254255 }
256+
255257 if ( mst . isNull && ! mst . isNull2 ) {
256258 // if master null version was put with an older
257259 // Cloudserver (or in compat mode), there is a
@@ -265,6 +267,7 @@ function processVersioningState(mst, vstat, nullVersionCompatMode) {
265267 }
266268 return { options, nullVersionId } ;
267269 }
270+
268271 // backward-compat: keep a reference to the existing null
269272 // versioned key
270273 if ( mst . nullVersionId ) {
@@ -295,6 +298,7 @@ function getMasterState(objMD) {
295298 if ( ! objMD ) {
296299 return { } ;
297300 }
301+
298302 const mst = {
299303 exists : true ,
300304 versionId : objMD . versionId ,
@@ -304,10 +308,12 @@ function getMasterState(objMD) {
304308 nullVersionId : objMD . nullVersionId ,
305309 nullUploadId : objMD . nullUploadId ,
306310 } ;
311+
307312 if ( objMD . location ) {
308313 mst . objLocation = Array . isArray ( objMD . location ) ?
309314 objMD . location : [ objMD . location ] ;
310315 }
316+
311317 return mst ;
312318}
313319/** versioningPreprocessing - return versioning information for S3 to handle
@@ -329,19 +335,22 @@ function versioningPreprocessing(bucketName, bucketMD, objectKey, objMD,
329335 log , callback ) {
330336 const mst = getMasterState ( objMD ) ;
331337 const vCfg = bucketMD . getVersioningConfiguration ( ) ;
332- // bucket is not versioning configured
338+
333339 if ( ! vCfg ) {
334340 const options = { dataToDelete : mst . objLocation } ;
335341 return process . nextTick ( callback , null , options ) ;
336342 }
337- // bucket is versioning configured
343+
338344 const { options, nullVersionId, delOptions } =
339345 processVersioningState ( mst , vCfg . Status , config . nullVersionCompatMode ) ;
346+
340347 return async . series ( [
341348 function storeNullVersionMD ( next ) {
342349 if ( ! nullVersionId ) {
343350 return process . nextTick ( next ) ;
344351 }
352+
353+ options . nullVersionId = nullVersionId ;
345354 return _storeNullVersionMD ( bucketName , objectKey , nullVersionId , objMD , log , next ) ;
346355 } ,
347356 function prepareNullVersionDeletion ( next ) {
0 commit comments