Skip to content

Commit

Permalink
fix: do not automatically set overrideUnlockedRetention (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelgrosso1 authored Mar 7, 2024
1 parent 11ebe2b commit c781bdc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3857,10 +3857,6 @@ class File extends ServiceObject<File, FileMetadata> {
options
);

if (metadata.retention !== undefined) {
options.overrideUnlockedRetention = true;
}

super
.setMetadata(metadata, options)
.then(resp => cb!(null, ...resp))
Expand Down
5 changes: 4 additions & 1 deletion system-test/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,10 @@ describe('storage', function () {

it('should disable object retention on the file', async () => {
const file = new File(objectRetentionBucket, fileName);
const [metadata] = await file.setMetadata({retention: null});
const [metadata] = await file.setMetadata(
{retention: null},
{overrideUnlockedRetention: true}
);
assert.strictEqual(metadata.retention, undefined);
});
});
Expand Down
9 changes: 6 additions & 3 deletions test/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4589,16 +4589,19 @@ describe('File', () => {
});

describe('setMetadata', () => {
it('should set query parameter overrideUnlockedRetention', done => {
it('should accept overrideUnlockedRetention option and set query parameter', done => {
const newFile = new File(BUCKET, 'new-file');

newFile.parent.request = (reqOpts: DecorateRequestOptions) => {
console.log(reqOpts.qs);
assert.strictEqual(reqOpts.qs.overrideUnlockedRetention, true);
done();
};

newFile.setMetadata({retention: null}, assert.ifError);
newFile.setMetadata(
{retention: null},
{overrideUnlockedRetention: true},
assert.ifError
);
});
});

Expand Down

0 comments on commit c781bdc

Please sign in to comment.