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

Bug fix: Sync public flag on object #260

Merged
merged 1 commit into from
May 2, 2024
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
28 changes: 12 additions & 16 deletions app/src/services/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,18 @@ const service = {

// Case: already synced - record & update public status as needed
if (comsObject) {
if (s3Public === undefined || s3Public === comsObject.public) {
response = await objectService.update({
id: comsObject.id,
userId: userId,
lastSyncedDate: new Date().toISOString()
}, trx);
} else {
response = await objectService.update({
id: comsObject.id,
userId: userId,
path: comsObject.path,
public: s3Public,
lastSyncedDate: new Date().toISOString()
}, trx);
modified = true;
}

response = await objectService.update({
id: comsObject.id,
userId: userId,
path: comsObject.path,
// update if public in s3
public: s3Public ? s3Public : comsObject.public,
lastSyncedDate: new Date().toISOString()
}, trx);

// if public flag changed mark as modified
Copy link
Contributor Author

@TimCsaky TimCsaky May 2, 2024

Choose a reason for hiding this comment

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

this line is not important.
marking the object as modified does nothing.
we had intended to use the modified flag to determine if versions needed syncing as well.. but we currently always syn the versions (so long as an object exists)

if (s3Public && !comsObject.public) modified = true;
}

// Case: not in COMS - insert new COMS object
Expand Down
4 changes: 2 additions & 2 deletions app/tests/unit/services/sync.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ describe('syncObject', () => {
const result = await service.syncObject(path, bucketId);

expect(result).toBeTruthy();
expect(result.modified).toBeTruthy();
expect(result.modified).toBeFalsy();
expect(result.object).toEqual(comsObject);

expect(ObjectModel.startTransaction).toHaveBeenCalledTimes(1);
Expand All @@ -448,7 +448,7 @@ describe('syncObject', () => {
expect(objectModelTrx.commit).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledWith(expect.objectContaining({
id: validUuidv4, path: path, public: false, lastSyncedDate: expect.anything(), userId: SYSTEM_USER
id: validUuidv4, path: path, public: true, lastSyncedDate: expect.anything(), userId: SYSTEM_USER
}), expect.any(Object));
});

Expand Down
Loading