From e7ec41eafeff9e281209efe9f941b043bc6b77f9 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Thu, 20 Mar 2025 22:26:19 +0000 Subject: [PATCH] Remove deleted files from DB --- frontend/sync-client/src/persistence/database.ts | 5 +++++ frontend/sync-client/src/sync-operations/syncer.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/sync-client/src/persistence/database.ts b/frontend/sync-client/src/persistence/database.ts index c2f12234..617cfbf1 100644 --- a/frontend/sync-client/src/persistence/database.ts +++ b/frontend/sync-client/src/persistence/database.ts @@ -151,6 +151,11 @@ export class Database { // No need to save as Promises don't get serialized } + public removeDocument(find: DocumentRecord): void { + this.documents = this.documents.filter((document) => document !== find); + this.save(); + } + public getLatestDocumentByRelativePath( find: RelativePath ): DocumentRecord | undefined { diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index 7ea50e93..7a7ba286 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -119,6 +119,8 @@ export class Syncer { ); resolve(); + + this.database.removeDocument(document); } catch (e) { reject(e); } finally { @@ -263,7 +265,7 @@ export class Syncer { const lastSeenUpdateId = this.database.getLastSeenUpdateId(); if ( lastSeenUpdateId === undefined || - remote.lastUpdateId > lastSeenUpdateId + lastSeenUpdateId < remote.lastUpdateId ) { this.database.setLastSeenUpdateId(remote.lastUpdateId); }