Skip to content

Commit

Permalink
Only populate lastSyncedDate when syncing object
Browse files Browse the repository at this point in the history
Previously, lastSyncedDate would be updated/populated on object update/create (even when not syncing) - this is incorrect behaviour
  • Loading branch information
norrisng-bc committed Feb 24, 2024
1 parent 95c68f5 commit 8351586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions app/src/services/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const service = {
active: data.active,
bucketId: data.bucketId,
createdBy: data.userId ?? SYSTEM_USER,
lastSyncedDate: new Date()
};
const response = await ObjectModel.query(trx).insert(obj).returning('*');

Expand Down Expand Up @@ -235,7 +234,7 @@ const service = {
public: data.public,
active: data.active,
updatedBy: data.userId ?? SYSTEM_USER,
lastSyncedDate: new Date()
lastSyncedDate: data.lastSyncedDate ? data.lastSyncedDate : undefined
});

if (!etrx) await trx.commit();
Expand Down
11 changes: 8 additions & 3 deletions app/src/services/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ const service = {
// Case: already synced - record & update public status as needed
if (comsObject) {
if (s3Public === undefined || s3Public === comsObject.public) {
response = comsObject;
response = await objectService.update({ id: comsObject.id, lastSyncedDate: new Date().toISOString() });
} else {
response = await objectService.update({
id: comsObject.id, userId: userId, path: comsObject.path, public: s3Public
id: comsObject.id,
userId: userId,
path: comsObject.path,
public: s3Public,
lastSyncedDate: new Date().toISOString()
});
modified = true;
}
Expand All @@ -179,7 +183,8 @@ const service = {
path: path,
public: s3Public,
bucketId: bucketId,
userId: userId
userId: userId,
lastSyncedDate: new Date().toISOString()
}, trx);

modified = true;
Expand Down

0 comments on commit 8351586

Please sign in to comment.