@@ -44,17 +44,43 @@ const acl = {
4444 objectMD . acl = addACLParams ;
4545 objectMD . originOp = 's3:ObjectAcl:Put' ;
4646
47- // Use storageType to determine if replication update is needed, as it is set only for
48- // "cloud" locations. This ensures that we reset replication when CRR is used, but not
49- // when multi-backend replication (i.e. Zenko) is used.
50- // TODO: this should be refactored to properly update the replication info, accounting
51- // for multiple rules and resetting the status only if needed CLDSRV-646
5247 const replicationInfo = getReplicationInfo ( config , objectKey , bucket , true ) ;
53- if ( replicationInfo && ! replicationInfo . storageType ) {
54- objectMD . replicationInfo = {
55- ...objectMD . replicationInfo ,
56- ...replicationInfo ,
57- } ;
48+
49+ // Split the storageClass and iterate over each one
50+ if ( replicationInfo ) {
51+ const storageClasses = replicationInfo . storageClass ? replicationInfo . storageClass . split ( ',' ) : [ ] ;
52+ const crrStorageClasses = [ ] ;
53+ const crrBackends = [ ] ;
54+
55+ // Iterate over each storage class and check isCRR
56+ storageClasses . forEach ( ( storageClass , index ) => {
57+ const trimmedStorageClass = storageClass . trim ( ) ;
58+ if ( config . locationConstraints &&
59+ config . locationConstraints [ trimmedStorageClass ] &&
60+ config . locationConstraints [ trimmedStorageClass ] . isCRR ) {
61+ // This storage class has CRR enabled, include it
62+ crrStorageClasses . push ( trimmedStorageClass ) ;
63+
64+ // Include corresponding backend if it exists
65+ if ( replicationInfo . backends && replicationInfo . backends [ index ] ) {
66+ crrBackends . push ( replicationInfo . backends [ index ] ) ;
67+ }
68+ }
69+ } ) ;
70+
71+ // Only set replication info for storage classes that have isCRR = true
72+ if ( crrStorageClasses . length > 0 ) {
73+ const filteredReplicationInfo = {
74+ ...replicationInfo ,
75+ storageClass : crrStorageClasses . join ( ',' ) ,
76+ backends : crrBackends
77+ } ;
78+
79+ objectMD . replicationInfo = {
80+ ...objectMD . replicationInfo ,
81+ ...filteredReplicationInfo ,
82+ } ;
83+ }
5884 }
5985
6086 return metadata . putObjectMD ( bucket . getName ( ) , objectKey , objectMD , params , log , cb ) ;
0 commit comments