From 383e2868c2cc76f5ee782ec6167bf74aaf65ff1a Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 24 May 2025 13:56:06 +0100 Subject: [PATCH] Small improvements --- .../src/file-operations/safe-filesystem-operations.ts | 2 +- frontend/sync-client/src/persistence/database.ts | 2 +- frontend/sync-client/src/sync-operations/syncer.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/sync-client/src/file-operations/safe-filesystem-operations.ts b/frontend/sync-client/src/file-operations/safe-filesystem-operations.ts index 6297af90..304723b2 100644 --- a/frontend/sync-client/src/file-operations/safe-filesystem-operations.ts +++ b/frontend/sync-client/src/file-operations/safe-filesystem-operations.ts @@ -60,7 +60,7 @@ export class SafeFileSystemOperations implements FileSystemOperations { } public async getFileSize(path: RelativePath): Promise { - this.logger.debug(`Getting size of file '${path}'`); + // Logging this would be too noisy return this.safeOperation( path, this.decorateToHoldLock(path, async () => diff --git a/frontend/sync-client/src/persistence/database.ts b/frontend/sync-client/src/persistence/database.ts index 3edbec80..f3b6011e 100644 --- a/frontend/sync-client/src/persistence/database.ts +++ b/frontend/sync-client/src/persistence/database.ts @@ -292,7 +292,7 @@ export class Database { return this.lastSeenUpdateIds.min; } - public addLastSeenUpdateId(value: number): void { + public addSeenUpdateId(value: number): void { const previousMin = this.lastSeenUpdateIds.min; this.lastSeenUpdateIds.add(value); if (previousMin !== this.lastSeenUpdateIds.min) { diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index aa7ff7fe..20e50120 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -385,7 +385,8 @@ export class Syncer { let hasLockToRelease = false; if (document === undefined) { - // Let's avoid the same documents getting created in parallel multiple times + // Let's avoid the same documents getting created in parallel multiple times. + // There might be multiple tasks waiting for the lock await this.remoteDocumentsLock.waitForLock( remoteVersion.documentId ); @@ -396,6 +397,7 @@ export class Syncer { } try { + // We're either the first one to get the lock, so we have to create the document in `unrestrictedSyncRemotelyUpdatedFile` if (document === undefined) { await this.syncQueue.add(async () => this.internalSyncer.unrestrictedSyncRemotelyUpdatedFile( @@ -427,7 +429,7 @@ export class Syncer { } } - this.database.addLastSeenUpdateId(remoteVersion.vaultUpdateId); + this.database.addSeenUpdateId(remoteVersion.vaultUpdateId); } finally { if (hasLockToRelease) { this.remoteDocumentsLock.unlock(remoteVersion.documentId);