Skip to content

Dedupe local attachments using pre-transcoded content hash - #6343

Open
diaruga777 wants to merge 5 commits into
signalapp:mainfrom
diaruga777:dedupeLocalVideo
Open

diaruga777 wants to merge 5 commits into
signalapp:mainfrom
diaruga777:dedupeLocalVideo

Conversation

@diaruga777

Copy link
Copy Markdown
image

Contributor checklist

Administrative:

Commits and testing:

  • My commits are rebased on the latest main branch.
  • My commits are well-structured for review.
  • My change has been thoroughly tested, and I am not aware of any regressions to existing features or behaviors.
  • I have tested my contribution on these devices:
  • iPhone 11, iOS 26.6
  • iPhone 16 pro, iOS 27 beta

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.

@max-signal
max-signal self-requested a review September 10, 2026 16:54
@max-signal max-signal self-assigned this Sep 10, 2026
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.

2 participants