@@ -36,31 +36,57 @@ const acl = {
36
36
} ,
37
37
38
38
addObjectACL ( bucket , objectKey , objectMD , addACLParams , params , log , cb ) {
39
- log . trace ( 'updating object acl in metadata' ) ;
40
- const isAclUnchanged = Object . keys ( objectMD . acl ) . length === Object . keys ( addACLParams ) . length
41
- && Object . keys ( objectMD . acl ) . every ( grant => this . _aclGrantDidNotChange ( grant , objectMD . acl , addACLParams ) ) ;
39
+ log . trace ( 'updating object acl in metadata' ) ;
40
+ const isAclUnchanged = Object . keys ( objectMD . acl ) . length === Object . keys ( addACLParams ) . length
41
+ && Object . keys ( objectMD . acl ) . every ( grant => this . _aclGrantDidNotChange ( grant , objectMD . acl , addACLParams ) ) ;
42
42
if ( ! isAclUnchanged ) {
43
43
/* eslint-disable no-param-reassign */
44
44
objectMD . acl = addACLParams ;
45
45
objectMD . originOp = 's3:ObjectAcl:Put' ;
46
46
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
52
47
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
+ }
58
84
}
59
85
60
86
return metadata . putObjectMD ( bucket . getName ( ) , objectKey , objectMD , params , log , cb ) ;
61
87
}
62
88
return cb ( ) ;
63
- } ,
89
+ }
64
90
65
91
parseAclFromHeaders ( params , cb ) {
66
92
const headers = params . headers ;
0 commit comments