[Fix] Same Filename with Different Content Creates New File#130
Merged
Conversation
Draft Changelog EntryChangelogFixed an issue where uploading a file with the same name but different content would create a duplicate file record in the database instead of creating a new version of the existing file. This fix also resolves a related bug where the storage location (S3 key) of the original file was being cleared when the same file was re-uploaded to a different document. The system now correctly maintains a single file record with proper version history and preserves the storage location across multiple documents. This changelog entry was automatically generated by the Changelog Generator Action. |
agritheory
reviewed
May 27, 2026
agritheory
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #129 — uploading a file with the same name but updated content left a duplicate
Filerecord in the database instead of adding a new version to the existing one. The fix also covers a related bug where the S3 key of the original file was silently cleared after re-uploading to a different document.Demo
Screen.Recording.2026-05-21.at.3.33.10.PM.mov
Tests
Added
test_file_versioning_different_documents: uploads the same file to two different documents and asserts that only oneFilerecord exists, the S3 key is preserved, and both documents appear infile_association. Also strengthened the existingtest_file_versioning_with_content_changeto assert the canonical file'scontent_hashactually changed after re-upload.