Skip to content

Commit 211296a

Browse files
committed
Merge branch 'improvement/CLDSRV-737' into q/9.1
2 parents 6891333 + 48eb17b commit 211296a

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

lib/utilities/collectResponseHeaders.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,7 @@ function collectResponseHeaders(objectMD, corsHeaders, versioningCfg,
104104
responseMetaHeaders['x-amz-replication-status'] =
105105
objectMD.replicationInfo.status;
106106
}
107-
if (objectMD.replicationInfo &&
108-
// Use storageType to determine if user metadata is needed.
109-
objectMD.replicationInfo.storageType &&
110-
Array.isArray(objectMD.replicationInfo.backends)) {
107+
if (Array.isArray(objectMD?.replicationInfo?.backends)) {
111108
objectMD.replicationInfo.backends.forEach(backend => {
112109
const { status, site, dataStoreVersionId } = backend;
113110
responseMetaHeaders[`x-amz-meta-${site}-replication-status`] =

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenko/cloudserver",
3-
"version": "9.1.0-preview.1",
3+
"version": "9.1.0",
44
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
55
"main": "index.js",
66
"engines": {

tests/unit/utils/collectResponseHeaders.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ describe('Middleware: Collect Response Headers', () => {
99
assert.deepStrictEqual(headers['x-amz-replication-status'], 'REPLICA');
1010
});
1111

12+
it('should set the replication status of each site', () => {
13+
const objectMD = {
14+
replicationInfo: {
15+
status: 'COMPLETED',
16+
backends: [
17+
{ site: 'us-east-1', status: 'COMPLETED', dataStoreVersionId: '123' },
18+
{ site: 'us-west-2', status: 'COMPLETED', dataStoreVersionId: '' },
19+
],
20+
},
21+
};
22+
const headers = collectResponseHeaders(objectMD);
23+
assert.deepStrictEqual(headers['x-amz-replication-status'], 'COMPLETED');
24+
assert.deepStrictEqual(headers['x-amz-meta-us-east-1-replication-status'],
25+
'COMPLETED');
26+
assert.deepStrictEqual(headers['x-amz-meta-us-east-1-version-id'], '123');
27+
assert.deepStrictEqual(headers['x-amz-meta-us-west-2-replication-status'],
28+
'COMPLETED');
29+
assert.deepStrictEqual(headers['x-amz-meta-us-west-2-version-id'], undefined);
30+
});
31+
1232
[
1333
{ md: { replicationInfo: null }, test: 'when config is not set' },
1434
{ md: {}, test: 'for older objects' },

0 commit comments

Comments
 (0)