Repository navigation
Dedupe local attachments using pre-transcoded content hash - #6343
Open
diaruga777 wants to merge 5 commits into
Open
diaruga777 wants to merge 5 commits into
diaruga777 wants to merge 5 commits into
Conversation
max-signal
self-requested a review
September 10, 2026 16:54
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.
Contributor checklist
Administrative:
Commits and testing:
Description
The problem: transcoding video is not byte-stable, but attachment deduplication is done via plaintext hash on the post-transcoding bytes. This means if you select the same source video from Photos picker twice for sending, you end up with t two separate Attachments, and you end up uploading twice.
This PR adds a localized optimization: compute and pass along pre-transcoding content hash and match against that at Attachment creation time to merge duplicates. This means the same Photos asset, selected twice in different chats, can take advantage of transit tier upload reuse.
This has no impact on other Attachment creation paths, does not affect any protos sent across the wire, and has no impact on backups. The only impact is to locally created attachments via the local video transcoding path that optionally match against existing locally-created attachments. This adds a new column to the Attachment table but does not migrate existing attachments; only new ones will be deduped in this way.
Tested on an iPhone and confirmed that 1. the same video selected twice doesn't reupload (it sends instantly! yay!) 2. a trimmed or otherwise modified video drops its deduplication hash and thus doesn't reuse a previously-sent unedited version 3. other attachment paths are unaffected.