From 83515863af596976cdb63ca38d8851104dda0f3c Mon Sep 17 00:00:00 2001 From: Norris Ng <103449568+norrisng-bc@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:18:28 -0800 Subject: [PATCH] Only populate lastSyncedDate when syncing object Previously, lastSyncedDate would be updated/populated on object update/create (even when not syncing) - this is incorrect behaviour --- app/src/services/object.js | 3 +-- app/src/services/sync.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/services/object.js b/app/src/services/object.js index 9b9bd192..632738d3 100644 --- a/app/src/services/object.js +++ b/app/src/services/object.js @@ -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('*'); @@ -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(); diff --git a/app/src/services/sync.js b/app/src/services/sync.js index 63012c38..dc9e4ea4 100644 --- a/app/src/services/sync.js +++ b/app/src/services/sync.js @@ -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; } @@ -179,7 +183,8 @@ const service = { path: path, public: s3Public, bucketId: bucketId, - userId: userId + userId: userId, + lastSyncedDate: new Date().toISOString() }, trx); modified = true;