Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: S3C-2726 remove some default attributes from ObjectMD #988

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions lib/models/ObjectMD.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ class ObjectMD {
},
'key': '',
'location': null,
'isNull': '',
'nullVersionId': '',
'isDeleteMarker': '',
'versionId': undefined, // If no versionId, it should be undefined
// versionId, isNull, nullVersionId and isDeleteMarker
// should be undefined when not set explicitly
'isNull': undefined,
Copy link
Contributor

@nicolas2bert nicolas2bert Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'isNull' and 'isDeleteMarker' are booleans and could be set to false by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to stay consistent with what cloudserver writes when it puts a new object, which has no such attributes in the metadata.

'nullVersionId': undefined,
'isDeleteMarker': undefined,
'versionId': undefined,
'tags': {},
'replicationInfo': {
status: '',
Expand Down Expand Up @@ -605,7 +607,7 @@ class ObjectMD {
* @return {boolean} Whether new version is null or not
*/
getIsNull() {
return this._data.isNull;
return this._data.isNull || false;
}

/**
Expand All @@ -622,7 +624,7 @@ class ObjectMD {
/**
* Get metadata nullVersionId value
*
* @return {string} The version id of the null version
* @return {string|undefined} The version id of the null version
*/
getNullVersionId() {
return this._data.nullVersionId;
Expand All @@ -645,7 +647,7 @@ class ObjectMD {
* @return {boolean} Whether object is a delete marker
*/
getIsDeleteMarker() {
return this._data.isDeleteMarker;
return this._data.isDeleteMarker || false;
}

/**
Expand All @@ -662,7 +664,7 @@ class ObjectMD {
/**
* Get metadata versionId value
*
* @return {string} The object versionId
* @return {string|undefined} The object versionId
*/
getVersionId() {
return this._data.versionId;
Expand All @@ -672,7 +674,7 @@ class ObjectMD {
* Get metadata versionId value in encoded form (the one visible
* to the S3 API user)
*
* @return {string} The encoded object versionId
* @return {string|undefined} The encoded object versionId
*/
getEncodedVersionId() {
return VersionIDUtils.encode(this.getVersionId());
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/models/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ describe('ObjectMD class setters/getters', () => {
['Key', 'key'],
['Location', null, []],
['Location', ['location1']],
['IsNull', null, ''],
['IsNull', null, false],
['IsNull', true],
['NullVersionId', null, ''],
['NullVersionId', null, undefined],
['NullVersionId', '111111'],
['IsDeleteMarker', null, ''],
['IsDeleteMarker', null, false],
['IsDeleteMarker', true],
['VersionId', null, undefined],
['VersionId', '111111'],
Expand Down