diff --git a/frontend/sync-client/src/sync-client.ts b/frontend/sync-client/src/sync-client.ts index 3ce3082f..33a1cac5 100644 --- a/frontend/sync-client/src/sync-client.ts +++ b/frontend/sync-client/src/sync-client.ts @@ -152,7 +152,8 @@ export class SyncClient { settings, syncService, fileOperations, - unrestrictedSyncer + unrestrictedSyncer, + contentCache ); const webSocketManager = new WebSocketManager( diff --git a/frontend/sync-client/src/sync-operations/syncer.ts b/frontend/sync-client/src/sync-operations/syncer.ts index 03041a36..1c8ac36e 100644 --- a/frontend/sync-client/src/sync-operations/syncer.ts +++ b/frontend/sync-client/src/sync-operations/syncer.ts @@ -17,6 +17,7 @@ import { createPromise } from "../utils/create-promise"; import { SyncResetError } from "../services/sync-reset-error"; import { Locks } from "../utils/locks"; import type { DocumentVersionWithoutContent } from "../services/types/DocumentVersionWithoutContent"; +import type { FixedSizeDocumentCache } from "../utils/fix-sized-cache"; export class Syncer { private readonly remoteDocumentsLock: Locks; @@ -33,7 +34,8 @@ export class Syncer { settings: Settings, private readonly syncService: SyncService, private readonly operations: FileOperations, - private readonly internalSyncer: UnrestrictedSyncer + private readonly internalSyncer: UnrestrictedSyncer, + private readonly contentCache: FixedSizeDocumentCache ) { this.syncQueue = new PQueue({ concurrency: settings.getSettings().syncConcurrency @@ -250,6 +252,7 @@ export class Syncer { public async reset(): Promise { await this.waitUntilFinished(); + this.contentCache.clear(); } public async syncRemotelyUpdatedFile( diff --git a/frontend/sync-client/src/utils/fix-sized-cache.ts b/frontend/sync-client/src/utils/fix-sized-cache.ts index bb4127bb..78baac14 100644 --- a/frontend/sync-client/src/utils/fix-sized-cache.ts +++ b/frontend/sync-client/src/utils/fix-sized-cache.ts @@ -54,4 +54,10 @@ export class FixedSizeDocumentCache { this.currentSizeInBytes -= lruEntry.byteLength; } } + + public clear(): void { + this.cache.clear(); + this.usageOrder = []; + this.currentSizeInBytes = 0; + } }