Skip to content

Commit ab22723

Browse files
Initialize replicationInfo if not present
This is especially needed in case the object was created before replication is enabled on the bucket. Issue: S3UTILS-76
1 parent 9df7207 commit ab22723

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

crrExistingObjects.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,31 @@ function _markObjectPending(
150150
return next();
151151
}
152152

153+
// Initialize replication info, if missing
154+
if (!objMD.getReplicationInfo()
155+
|| !objMD.getReplicationSiteStatus(storageClass)) {
156+
const { Rules, Role } = repConfig;
157+
const destination = Rules[0].Destination.Bucket;
158+
// set replication properties
159+
const ops = objMD.getContentLength() === 0 ? ['METADATA']
160+
: ['METADATA', 'DATA'];
161+
const backends = [{
162+
site: storageClass,
163+
status: 'PENDING',
164+
dataStoreVersionId: '',
165+
}];
166+
const replicationInfo = {
167+
status: 'PENDING',
168+
backends,
169+
content: ops,
170+
destination,
171+
storageClass,
172+
role: Role,
173+
storageType: STORAGE_TYPE,
174+
};
175+
objMD.setReplicationInfo(replicationInfo);
176+
}
177+
153178
objMD.setReplicationSiteStatus(storageClass, 'PENDING');
154179
objMD.setReplicationStatus('PENDING');
155180
objMD.updateMicroVersionId();

0 commit comments

Comments
 (0)