Skip to content

Commit

Permalink
ARSN-178: set to undefined to clear MD
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed May 12, 2022
1 parent a0010ef commit 3388de6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/models/ObjectMD.js
Original file line number Diff line number Diff line change
Expand Up @@ -1208,16 +1208,20 @@ class ObjectMD {
/**
* Set x-amz-restore
*
* @param {ObjectMDAmzRestore} value x-amz-restore object
* @param {ObjectMDAmzRestore|undefined} value x-amz-restore object
* @returns {ObjectMD} itself
* @throws {Error} case of invalid parameter
*/
setAmzRestore(value) {
// Accept object instance of ObjectMDAmzRestore and Object
if (!(value instanceof ObjectMDAmzRestore) && !ObjectMDAmzRestore.isValid(value)) {
throw new Error('x-amz-restore must be type of ObjectMDAmzRestore.');
if (value) {
// Accept object instance of ObjectMDAmzRestore and Object
if (!(value instanceof ObjectMDAmzRestore) && !ObjectMDAmzRestore.isValid(value)) {
throw new Error('x-amz-restore must be type of ObjectMDAmzRestore.');
}
this._data['x-amz-restore'] = value;
} else {
delete this._data['x-amz-restore'];
}
this._data['x-amz-restore'] = value;
return this;
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/models/ObjectMD.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ describe('ObjectMD class setters/getters', () => {
});
});
});

it('ObjectMD::setAmzRestore should clear AmzRestore', () => {
md.setAmzRestore();
assert.deepStrictEqual(md.getAmzRestore(), undefined);
});
});

describe('ObjectMD import from stored blob', () => {
Expand Down

0 comments on commit 3388de6

Please sign in to comment.