As an admin I want to backfill file hashes for already-uploaded documents so existing files are covered by the annotation versioning feature #56
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?
Context
Issue #55 introduces a
file_hash(SHA-256) column ondocumentsanddocument_annotations. New uploads will populate it automatically, but documents uploaded before the migration will havefile_hash = NULL.Without backfilling, those documents will always show a "stale annotations" notice (NULL ≠ any hash), and their annotations will be hidden.
User Journey
An admin opens the System tab in the admin panel and clicks "Datei-Hashes berechnen". The backend streams through all documents where
file_hash IS NULL, downloads each file from MinIO, computes SHA-256, and writes it back. A progress indicator shows how many files have been processed. When done, a success message confirms the count.E2E Scenarios
Implementation notes
POST /api/admin/backfill-file-hashesendpoint (mirrors the existingbackfill-versionspattern inDocumentController)DocumentService.backfillFileHashes(): paginate through documents withfileHash IS NULLANDs3Key IS NOT NULL, download each fromFileService, compute SHA-256, saveMessageDigest.getInstance("SHA-256")— no new dependencyadmin/+page.svelteSystem tab alongside the existing "Versionen nachfüllen" carddocument_annotations.file_hashfor any annotations that already exist: set them to the document'sfile_hashafter computing it (reasonable assumption — annotations were created against the file that was current at the time)Dependency
Implement after #55.