From eee1d8db1bf617536607a3ab099dfac3d7601b76 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Fri, 3 Jan 2025 11:35:12 +0000 Subject: [PATCH] Fix error --- plugin/src/sync-operations/syncer.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/plugin/src/sync-operations/syncer.ts b/plugin/src/sync-operations/syncer.ts index 752c9db..8d80438 100644 --- a/plugin/src/sync-operations/syncer.ts +++ b/plugin/src/sync-operations/syncer.ts @@ -350,7 +350,7 @@ export class Syncer { if (!metadata) { // Perhaps the file has been moved. Let's check by looking at the deleted files const originalFile = - await findMatchingFileBasedOnHash( + await this.findMatchingFileBasedOnHash( relativePath, locallyDeletedFiles ); @@ -614,17 +614,19 @@ export class Syncer { await this.database.setLastSeenUpdateId(responseVaultUpdateId); } } -} -async function findMatchingFileBasedOnHash( - filePath: RelativePath, - candidates: [RelativePath, DocumentMetadata][] -): Promise<[RelativePath, DocumentMetadata] | undefined> { - const contentHash = hash(await this.operations.read(filePath)); + private async findMatchingFileBasedOnHash( + filePath: RelativePath, + candidates: [RelativePath, DocumentMetadata][] + ): Promise<[RelativePath, DocumentMetadata] | undefined> { + const contentHash = hash(await this.operations.read(filePath)); - if (contentHash != EMPTY_HASH) { - return undefined; + if (contentHash != EMPTY_HASH) { + return undefined; + } + + return candidates.find( + ([_, document]) => document.hash === contentHash + ); } - - return candidates.find(([_, document]) => document.hash === contentHash); }