fix(files): reuse a stored file by digest only for the same uploader #66
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/support!66
Loading…
Reference in a new issue
No description provided.
Delete branch "MEDECA-630-dedup-same-uploader"
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?
Summary
For MEDECA-630.
MongoFileStore.store(name, Array[Byte], metadata)deduplicated by SHA-256 across all callers. It returned the existing file, which keeps its first uploader'suploadedBy. A Klient who uploads the same bytes as another user then gets a file not recorded as theirs, and MEDECA's "the caller uploaded this file" check refuses their own upload.New rule: reuse a stored file only when its
uploadedByequals the uploader of this call; otherwise store a new file stamped with this call's uploader.uploadedByafterwithUploader: the current user when there is one, else the value inmetadata.FileReprstore paths do not deduplicate and are unchanged. Existing deduplicated files keep their first uploader.Same patch on
release/0.1.x: the 0.1.x PR.MongoFileStoreand its dependencies are identical on both lines.0.1.25 is to carry this change together with the MEDECA-655 workflow change.
Tests
New
MongoFileStoreIntegrationSpec(files/adapters/mongo/it) runs against a real MongoDB named byMONGO_URI(skipped when unset, as the existing spec in that module). It uses its own database per run and drops it at the end.MONGO_URI=mongodb://localhost:<port> ./mill filesMongo.it.testOnly works.iterative.core.service.impl.MongoFileStoreIntegrationSpecagainst a disposablemongo:5container: 7 passed, 0 failed. Before the fix: 3 passed, 4 failed (the 4 new-rule cases)../mill __.test: passed. Note that__.testdoes not includefilesMongo.it(its task istestForked), so CI does not run this spec.Known pre-existing defect (not changed here):
MongoJsonFileRepositoryIntegrationSpecin the same module connects tolocalhost:27017even whenMONGO_URIis set, becauseMongoClient.layerreads the config through the test environment, which is empty. It fails when nothing listens on 27017. The new spec reads the liveMONGO_URIand avoids this.🤖 Generated with Claude Code