Rematch documents by content fingerprint on upload and session open.
Re-uploading the same PDF attaches bytes to the existing document (keeping evidence) instead of creating a twin. On restore, merge duplicate fingerprint groups and migrate annotations onto the evidence-bearing primary.
This commit is contained in:
parent
a73d45bfac
commit
1fb1841173
7 changed files with 464 additions and 14 deletions
|
|
@ -21,6 +21,8 @@ import {
|
|||
usePdfByteStore,
|
||||
} from "@work/index";
|
||||
|
||||
import { registerOrRematchDocument } from "./document-rematch";
|
||||
|
||||
import manifest from "../../../fixtures/pdfs/manifest.json";
|
||||
|
||||
interface Fixture {
|
||||
|
|
@ -60,16 +62,15 @@ export function SampleSessions() {
|
|||
const { document, representation } = await ingestPdf(bytes, {
|
||||
filename: fixture.filename,
|
||||
});
|
||||
// Push the bytes into the byte store so the viewer can mount them via
|
||||
// the same blob URL machinery used by the upload path. The document
|
||||
// record carries the blob URL on `uri` for the viewer adapter.
|
||||
// Same blob URL machinery as the upload path, with fingerprint rematch
|
||||
// so reloading a sample reattaches to an existing session document.
|
||||
const record = byteStore.put(document.id, bytes);
|
||||
engine.documents.register({
|
||||
const outcome = registerOrRematchDocument(engine, byteStore, {
|
||||
document: { ...document, uri: record.blobUrl },
|
||||
representation,
|
||||
});
|
||||
setByFixture((prev) => ({ ...prev, [fixture.id]: document.id }));
|
||||
setId(document.id);
|
||||
setByFixture((prev) => ({ ...prev, [fixture.id]: outcome.documentId }));
|
||||
setId(outcome.documentId);
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue