As an admin I want annotations to stay linked to their file version so they disappear when a different file is uploaded but reappear if the original file is re-uploaded #55
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Annotations are currently stored against a document, not against a specific file. If an admin uploads a replacement file, all existing annotations remain visible even though they point at coordinates on a different page layout. Conversely, if the wrong file was uploaded by accident and corrected, the annotations are lost.
Solution: content-based file hash
Compute a SHA-256 hash of the file bytes on every upload (UI and mass import). Store it as
file_hashon the document. Each annotation stores thefile_hashthat was current when the annotation was created.The frontend renders annotations only when
annotation.fileHash == document.fileHash. When they differ, show a non-blocking notice:This is content-based, so uploading the exact same file twice (even with a different filename) correctly restores the annotations.
User Journey
Admin opens a document with annotations on page 1. They realise they scanned the wrong page and upload the correct scan. The annotation highlight disappears and a notice explains it belongs to the previous file. The admin re-uploads the original scan — the annotation reappears automatically without any manual action.
E2E Scenarios
Implementation notes
file_hash VARCHAR(64)column todocuments(Flyway migration); compute SHA-256 inFileService.upload()and store on the documentfile_hash VARCHAR(64)column todocument_annotations; set fromdocument.fileHashat annotation creation timeMassImportServicecallsFileServicealready — hash computed there automaticallyfileHashonDocumentResponse; exposefileHashonAnnotationResponse; filter annotation rendering accordingly; show notice when at least one annotation has a different hash