Fix syncing when network latency is present #4

Merged
schmelczer merged 58 commits from asch/fixes into master 2025-03-16 20:13:50 +00:00
Showing only changes of commit c250e82998 - Show all commits
Andras Schmelczer 2025-03-02 18:27:02 +00:00
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -0,0 +1,14 @@
import type { DocumentMetadata, RelativePath } from "../persistence/database";
import { EMPTY_HASH } from "./hash";
// TODO: make this smarter so that offline files can be renamed & edited at the same time
export function findMatchingFile(
contentHash: string,
candidates: [RelativePath, DocumentMetadata][]
): [RelativePath, DocumentMetadata] | undefined {
if (contentHash === EMPTY_HASH) {
return undefined;
}
return candidates.find(([_, metadata]) => metadata.hash === contentHash);
}