This commit is contained in:
Andras Schmelczer 2026-04-28 22:20:31 +01:00
parent 1163da826e
commit 5776a37dc9
13 changed files with 652 additions and 181 deletions

View file

@ -1,18 +1,14 @@
import type {
DocumentRecord,
DocumentWithPath,
RelativePath
} from "../sync-operations/types";
import type { DocumentRecord } from "../sync-operations/types";
import { EMPTY_HASH } from "./hash";
// TODO: make this smarter so that offline files can be renamed & edited at the same time
export async function findMatchingFile(
contentHash: string,
candidates: { path: RelativePath; record: DocumentRecord }[]
): Promise<DocumentWithPath | undefined> {
candidates: DocumentRecord[]
): Promise<DocumentRecord | undefined> {
if (contentHash === (await EMPTY_HASH)) {
return undefined;
}
return candidates.find(({ record }) => record.remoteHash === contentHash);
return candidates.find((record) => record.remoteHash === contentHash);
}