Skip to content

Commit

Permalink
Keep existing public status after object update
Browse files Browse the repository at this point in the history
when uploading a new version or modifying metadata,
let object keep existing public status in db.
  • Loading branch information
TimCsaky committed May 21, 2024
1 parent 71ee983 commit 0221e4b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
7 changes: 0 additions & 7 deletions app/src/controllers/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ const controller = {
const s3Response = await storageService.copyObject(data);

await utils.trxWrapper(async (trx) => {
// set public flag to false
await objectService.update({ id: objId, userId: userId, path: objPath, public: false });

// create or update version in DB (if a non-versioned object)
const version = s3Response.VersionId ?
await versionService.copy(
Expand Down Expand Up @@ -848,9 +845,6 @@ const controller = {
const s3Response = await storageService.copyObject(data);

await utils.trxWrapper(async (trx) => {
// set public flag to false
await objectService.update({ id: objId, userId: userId, path: objPath, public: false });

// create or update version (if a non-versioned object)
const version = s3Response.VersionId ?
await versionService.copy(
Expand Down Expand Up @@ -1030,7 +1024,6 @@ const controller = {
name: filename,
mimeType: req.currentUpload.mimeType,
metadata: getMetadata(req.headers),
public: false, // New uploads always default to private ACL status
tags: {
...req.query.tagset,
'coms-id': objId // Enforce `coms-id:<objectId>` tag
Expand Down
8 changes: 2 additions & 6 deletions app/tests/unit/controllers/object.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ describe('addMetadata', () => {
});

expect(trxWrapperSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledWith(expect.objectContaining({ public: false }));
expect(versionCopySpy).toHaveBeenCalledTimes(1);
expect(metadataAssociateMetadataSpy).toHaveBeenCalledTimes(1);
expect(tagAssociateTagsSpy).toHaveBeenCalledTimes(1);
Expand All @@ -123,7 +121,7 @@ describe('addTags', () => {

it('should add the new tags', async () => {
// response from S3
const getObjectTaggingResponse = { TagSet: []};
const getObjectTaggingResponse = { TagSet: [] };

// request object
const req = {
Expand Down Expand Up @@ -165,7 +163,7 @@ describe('addTags', () => {
const req = {
params: { objectId: 'xyz-789' },
query: {
tagset: { a: '1', b: '2', c: '3', d: '4', e: '5', f: '6', g: '7', h: '8', i: '9', j: '10'}
tagset: { a: '1', b: '2', c: '3', d: '4', e: '5', f: '6', g: '7', h: '8', i: '9', j: '10' }
}
};
getCurrentUserIdSpy.mockReturnValue('user-123');
Expand Down Expand Up @@ -567,8 +565,6 @@ describe('replaceMetadata', () => {
});

expect(trxWrapperSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledWith(expect.objectContaining({ public: false }));
expect(versionCopySpy).toHaveBeenCalledTimes(1);
expect(metadataAssociateMetadataSpy).toHaveBeenCalledTimes(1);
expect(tagAssociateTagsSpy).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 0221e4b

Please sign in to comment.