From eeb7999d76126f2bebec1de338a709e954ca338e Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 23 Feb 2025 11:31:03 +0000 Subject: [PATCH] Reset locks --- frontend/sync-client/src/sync-operations/document-locks.ts | 5 +++++ frontend/sync-client/src/sync-operations/syncer.ts | 3 ++- .../sync-client/src/sync-operations/unrestricted-syncer.ts | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/sync-client/src/sync-operations/document-locks.ts b/frontend/sync-client/src/sync-operations/document-locks.ts index f1831f82..e8e0eb13 100644 --- a/frontend/sync-client/src/sync-operations/document-locks.ts +++ b/frontend/sync-client/src/sync-operations/document-locks.ts @@ -47,4 +47,9 @@ export class DocumentLocks { this.locked.delete(relativePath); } } + + public reset(): void { + this.locked.clear(); + this.waiters.clear(); + } } diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index 652d9c51..454ce5a0 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -157,6 +157,7 @@ export class Syncer { this.remainingOperationsListeners.forEach((listener) => { listener(0); }); + this.internalSyncer.reset(); } private async syncRemotelyUpdatedFile( @@ -214,7 +215,7 @@ export class Syncer { ); this.logger.debug( - `Document ${relativePath} was not found under its current path in the database but was found under a different path ${originalFile[0]}, scheduling sync to move it` + `Document '${originalFile[0]}' was not found under its current path in the database but was found under a different path (${relativePath}), scheduling sync to move it` ); return this.internalSyncer.unrestrictedSyncLocallyUpdatedFile( { diff --git a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts index 6db8b005..2ddc29f3 100644 --- a/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts +++ b/frontend/sync-client/src/sync-operations/unrestricted-syncer.ts @@ -527,7 +527,11 @@ export class UnrestrictedSyncer { } } - public async tryIncrementVaultUpdateId( + public reset(): void { + this.locks.reset(); + } + + private async tryIncrementVaultUpdateId( responseVaultUpdateId: number ): Promise { if (this.database.getLastSeenUpdateId() === responseVaultUpdateId - 1) {