@@ -543,6 +543,18 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
543543 let versionId = decodeVersionId ( request . query ) ;
544544 let versioning = bucketInfo . isVersioningEnabled ( ) ;
545545 let isNull = false ;
546+ const storageType = headers [ 'x-scal-storage-type' ] ;
547+ let versioningNotImpl = false ;
548+ console . info ( 'storage type' , { storageType, versioningNotImplBackends : constants . versioningNotImplBackends } ) ;
549+
550+ if ( constants . versioningNotImplBackends [ storageType ] ) {
551+ log . debug (
552+ 'versioning is not implemented on the destination backend' ,
553+ { method : 'putMetadata' , error : errors . NotImplemented } ,
554+ ) ;
555+
556+ versioningNotImpl = true ;
557+ }
546558
547559 if ( versionId === 'null' ) {
548560 isNull = true ;
@@ -616,10 +628,13 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
616628 // To prevent this, the versionId field is only included in options when it is defined.
617629 if ( versionId !== undefined ) {
618630 options . versionId = versionId ;
619- omVal . versionId = versionId ;
620631
621- if ( isNull ) {
622- omVal . isNull = isNull ;
632+ if ( ! versioningNotImpl ) {
633+ omVal . versionId = versionId ;
634+
635+ if ( isNull ) {
636+ omVal . isNull = isNull ;
637+ }
623638 }
624639
625640 // In the MongoDB metadata backend, setting the versionId option leads to the creation
@@ -663,21 +678,24 @@ function putMetadata(request, response, bucketInfo, objMd, log, callback) {
663678 } ) ;
664679 } ,
665680 async ( ) => {
666- if ( versioning && ! objMd ) {
667- const masterObjectAndBucket =
668- await metadata . getBucketAndObjectMDPromised ( bucketName , objectKey , { } , log ) ;
681+ if ( ! versioning || objMd || versioningNotImpl ) {
682+ console . info ( 'skipping versioning preprocessing' , { versioning, hasObjMd : ! ! objMd } ) ;
683+ return ;
684+ }
669685
670- if ( ! masterObjectAndBucket . obj ) {
671- return ;
672- }
686+ const masterObjectAndBucket =
687+ await metadata . getBucketAndObjectMDPromised ( bucketName , objectKey , { } , log ) ;
673688
674- const masterObject = JSON . parse ( masterObjectAndBucket . obj ) ;
675- const versioningPreprocessingResult =
676- await versioningPreprocessingPromised ( bucketName , bucketInfo , objectKey , masterObject , log ) ;
689+ if ( ! masterObjectAndBucket . obj ) {
690+ return ;
691+ }
677692
678- if ( versioningPreprocessingResult ?. nullVersionId ) {
679- omVal . nullVersionId = versioningPreprocessingResult . nullVersionId ;
680- }
693+ const masterObject = JSON . parse ( masterObjectAndBucket . obj ) ;
694+ const versioningPreprocessingResult =
695+ await versioningPreprocessingPromised ( bucketName , bucketInfo , objectKey , masterObject , log ) ;
696+
697+ if ( versioningPreprocessingResult ?. nullVersionId ) {
698+ omVal . nullVersionId = versioningPreprocessingResult . nullVersionId ;
681699 }
682700 } ,
683701 next => {
0 commit comments