Skip to content

fix(images): clear the image cache on sign-out - #110

Merged
simonhamp merged 1 commit into
NativePHP:mainfrom
jubianchi:fix/clear-image-cache-on-sign-out
Oct 28, 2026
Merged

simonhamp merged 1 commit into
NativePHP:mainfrom
jubianchi:fix/clear-image-cache-on-sign-out

Conversation

@jubianchi

@jubianchi jubianchi commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Found while reviewing the app bundled in the iOS 1.0.2 TestFlight build.

Account::forget() empties the response cache, the stash and the outbox, but not storage/app/image-cache. Old images are only pruned by the first DownloadImages task of a later launch, and nothing downloads once you're signed out. So the avatars, commit images and link preview images the last person saw (Remotes ones included) stayed on the phone indefinitely. It might be intentional for some images (the ones from the log because they are public) but not those from Remotes.

  • ImageCache::clear() deletes the folder and forgets what each URL was drawn from this launch, so nothing points at a deleted file.
  • Account::forget() calls it next to ResponseCache::flush().
  • DownloadImages::save() checks that someone is still signed in after each batch arrives and before writing it, so a download already running on a background thread can't put images back once the folder is gone. The cache store is the shared SQLite database, so the background thread sees the sign-out. I chose this over a per-user folder (image-cache/{userId}), which would touch every path in ImageCache for little gain once the folder is cleared on sign-out.

Tests

  • Signing out deletes the folder and draws a previously cached image from its URL again.
  • save() keeps nothing when nobody is signed in.
  • The existing download tests now sign in first, as the app always is when it downloads.

Screenshots

  • No visible change

🤖 Generated with Claude Code

Account::forget() emptied the response cache, the stash and the outbox,
but left storage/app/image-cache alone. Pruning only runs in the first
download of a later launch, and nothing downloads once you are signed
out, so the images the last person saw (avatars, commit images, link
previews) stayed on the phone indefinitely.

Sign-out now deletes the folder and forgets what each URL was drawn
from, so nothing points at a deleted file. A download already running
on a background thread checks that someone is still signed in before
it writes, so it can't put images back after the folder is gone.

🤖 Généré avec Claude Code
@jubianchi
jubianchi marked this pull request as ready for review October 27, 2026 23:16
@simonhamp

Copy link
Copy Markdown
Member

good call

@simonhamp
simonhamp merged commit 4697195 into NativePHP:main Oct 28, 2026
4 checks passed
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