Skip to content

Commit

Permalink
Merge branch 'improvement/ARSN-411' into q/8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-e committed Nov 19, 2024
2 parents 6a33bcc + 0a2388b commit fed5807
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
35 changes: 19 additions & 16 deletions lib/models/ObjectMD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export type ReplicationInfo = {
role: string;
storageType: string;
dataStoreVersionId: string;
isNFS: boolean | null;
isNFS?: boolean;
};

export type ObjectMDData = {
'owner-display-name': string;
'owner-id': string;
'cache-control': string;
'content-disposition': string;
'content-language': string;
'content-language'?: string;
'content-encoding': string;
'creation-time'?: string;
'last-modified'?: string;
Expand Down Expand Up @@ -84,12 +84,12 @@ export type ObjectMDData = {
// Used for keeping object metadata in the oplog event
// In case of a deletion the flag is first updated before
// deleting the object
deleted: boolean;
deleted?: boolean;
// PHD flag indicates whether the object is a temporary placeholder.
// This is the case when the latest version of an object gets deleted
// the master is set as a placeholder and gets updated with the new latest
// version data after a certain amount of time.
isPHD: boolean;
isPHD?: boolean;
};

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class ObjectMD {
'content-length': 0,
'content-type': '',
'content-md5': '',
'content-language': '',
'content-language': undefined,
'creation-time': undefined,
// simple/no version. will expand once object versioning is
// introduced
Expand All @@ -197,7 +197,7 @@ export default class ObjectMD {
'x-amz-server-side-encryption-aws-kms-key-id': '',
'x-amz-server-side-encryption-customer-algorithm': '',
'x-amz-website-redirect-location': '',
'x-amz-scal-transition-in-progress': false,
'x-amz-scal-transition-in-progress': undefined,
acl: {
Canned: 'private',
FULL_CONTROL: [],
Expand Down Expand Up @@ -227,12 +227,12 @@ export default class ObjectMD {
role: '',
storageType: '',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
},
dataStoreName: '',
originOp: '',
deleted: false,
isPHD: false,
deleted: undefined,
isPHD: undefined,
};
}

Expand All @@ -250,7 +250,10 @@ export default class ObjectMD {
// objMd is a new JS object created for the purpose, it's safe
// to just assign its top-level properties.

Object.assign(this._data, objMd);
const { replicationInfo, ...md } = objMd as ObjectMDData;
Object.assign(this._data, md);
// keep default values inside replicationInfo
Object.assign(this._data.replicationInfo, replicationInfo);
this._convertToLatestModel();
}

Expand Down Expand Up @@ -479,7 +482,7 @@ export default class ObjectMD {
* @return content-language
*/
getContentLanguage() {
return this._data['content-language'];
return this._data['content-language'] || '';
}

/**
Expand Down Expand Up @@ -677,7 +680,7 @@ export default class ObjectMD {
* @return True if transition is in progress, false otherwise
*/
getTransitionInProgress() {
return this._data['x-amz-scal-transition-in-progress'];
return !!this._data['x-amz-scal-transition-in-progress'];
}

/**
Expand Down Expand Up @@ -1065,7 +1068,7 @@ export default class ObjectMD {
role,
storageType: storageType || '',
dataStoreVersionId: dataStoreVersionId || '',
isNFS: isNFS || null,
isNFS,
};
return this;
}
Expand Down Expand Up @@ -1099,7 +1102,7 @@ export default class ObjectMD {
* @return Whether replication from an NFS bucket
*/
getReplicationIsNFS() {
return this._data.replicationInfo.isNFS;
return !!this._data.replicationInfo.isNFS;
}

setReplicationSiteStatus(site: string, status: string) {
Expand Down Expand Up @@ -1461,7 +1464,7 @@ export default class ObjectMD {
* @return {Boolean}
*/
getDeleted() {
return this._data.deleted;
return !!this._data.deleted;
}

/**
Expand All @@ -1479,6 +1482,6 @@ export default class ObjectMD {
* @return {Boolean}
*/
getIsPHD() {
return this._data.isPHD;
return !!this._data.isPHD;
}
}
6 changes: 3 additions & 3 deletions tests/unit/models/ObjectMD.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('ObjectMD class setters/getters', () => {
role: '',
storageType: '',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
}],
['ReplicationInfo', {
status: 'PENDING',
Expand All @@ -114,10 +114,10 @@ describe('ObjectMD class setters/getters', () => {
'arn:aws:iam::account-id:role/dest-resource',
storageType: 'aws_s3',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
}],
['DataStoreName', null, ''],
['ReplicationIsNFS', null, null],
['ReplicationIsNFS', null, false],
['ReplicationIsNFS', true],
['AzureInfo', {
containerPublicAccess: 'container',
Expand Down

0 comments on commit fed5807

Please sign in to comment.