Skip to content

[Fix] Same Filename with Different Content Creates New File#130

Merged
agritheory merged 4 commits into
version-15from
issue-129
May 28, 2026
Merged

[Fix] Same Filename with Different Content Creates New File#130
agritheory merged 4 commits into
version-15from
issue-129

Conversation

@lauty95

@lauty95 lauty95 commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #129 — uploading a file with the same name but updated content left a duplicate File record 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 one File record exists, the S3 key is preserved, and both documents appear in file_association. Also strengthened the existing test_file_versioning_with_content_change to assert the canonical file's content_hash actually changed after re-upload.

@github-actions

Copy link
Copy Markdown

Draft Changelog Entry

Changelog

Fixed 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.

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py11554%13–14, 20–22
commands.py35350%4–6, 9–11, 17–20, 23, 26–27, 49–51, 53–54, 56, 65, 68–72, 75–76, 85–87, 89–90, 92, 94, 97
hooks.py140100% 
install.py36360%4–7, 10–11, 14–18, 21–27, 30–34, 36–39, 41–49
migration.py19611839%25, 46, 68–69, 88–89, 96, 115, 118–120, 123–125, 158–159, 161–162, 166–168, 171–172, 187, 196–197, 199–203, 205–210, 212, 219–221, 223, 225–226, 228, 235–236, 238–242, 244–247, 249, 254–257, 259–268, 270–279, 281–282, 284–285, 287–288, 290–294, 298–301, 305, 307–308, 310, 312–314, 317–318, 320–321, 323–329, 331–332, 334, 336
cloud_storage
   __init__.py00100% 
cloud_storage/doctype
   __init__.py00100% 
cloud_storage/doctype/file_association
   __init__.py00100% 
   file_association.py30100% 
cloud_storage/doctype/file_version
   __init__.py00100% 
   file_version.py30100% 
cloud_storage/overrides
   file.py41713068%66, 76, 96, 109, 126, 140, 148–149, 162, 166–167, 179, 194, 199, 206, 221, 279–288, 290–298, 309, 314–315, 323–325, 327, 332, 338, 340, 356, 360, 365, 373–374, 377, 380, 409, 454, 457, 496, 502, 508, 514, 520, 526, 536, 538–540, 544, 552–554, 556, 574, 589–593, 599–600, 602, 625–629, 641–642, 691, 694–703, 710–711, 713–715, 718–719, 724–726, 728, 733–736, 741, 743, 755–756, 758, 763–767, 769, 780–786
config
   __init__.py00100% 
   desktop.py330%4, 7–8
   docs.py660%4, 6–8, 12–13
tests
   conftest.py44197%54
   test_file.py189398%89, 174, 257
   test_file_preview.py630100% 
   test_local_storage.py610100% 
TOTAL108133768% 

@lauty95 lauty95 requested a review from agritheory May 21, 2026 19:00
Comment thread cloud_storage/cloud_storage/overrides/file.py Outdated
@agritheory agritheory merged commit 9395f69 into version-15 May 28, 2026
6 checks passed
@agritheory agritheory deleted the issue-129 branch May 28, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Same Filename with Different Content Creates New File

2 participants