Purge cached full images when messages are deleted - #1672
Merged
Conversation
dnlbui
force-pushed
the
issue-1656-delete-full-image-cache-phase2
branch
from
September 1, 2026 20:33
6415210 to
2514e01
Compare
osyed
force-pushed
the
issue-1656-delete-full-image-cache-phase2
branch
from
September 1, 2026 23:06
9b5085f to
c7f5265
Compare
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.
What Changed
This PR makes the Phase 1 full-image cache lifecycle-safe and bounded.
purgeImageCachesremoves both thumbnail and full-resolution records when image attachments are removed locally or through an accepted delete-for-all event.shouldCacheguard prevents an in-progress Save from writing a decrypted image back after its message has been deleted.FullImageCache.put()now evicts records in first-in, first-out order using the existingcachedAtindex when an incoming image would exceed the 250 MiB budget.Fixed Flow
cachedAtfrom oldest to newest and deletes only enough records to make room.Why
Phase 1 persisted decrypted images but did not connect them to message deletion, and its size check permanently stopped caching newer images after the cache filled. Coordinating deletion with pending Saves prevents removed images from being restored, while atomic FIFO eviction keeps the cache useful for newer images without exceeding its application budget.
Validation
node --test tests/issue-1656-full-image-cache.test.mjs tests/popup-select-container.test.mjsnode --check app.jsgit diff --check issue-1656-save-image-cache-phase1...HEADDepends on #1671
Related to #1656