fix: clean account caches on deletion#1265
Merged
andrinoff merged 2 commits intoMay 12, 2026
Merged
Conversation
Member
|
big PR, i'll check it out later, thx @FromSi |
Member
|
I'll review these changes way later, very busy at the moment, won't release the next version without this, so no worries |
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?
This PR updates contact usage tracking and cleans account-owned cache data when an account is deleted.
Commit 1: contact usage per account
Contacts now store usage metadata per account instead of a single global
last_used/use_countpair.Old contact JSON:
{ "name": "Alice", "email": "alice@example.com", - "last_used": "2026-05-06T19:29:28.502623767+05:00", - "use_count": 1 }New contact JSON:
{ "name": "Alice", "email": "alice@example.com", + "usage_by_account": { + "account-id": { + "last_used": "2026-05-06T19:29:28.502623767+05:00", + "use_count": 1 + } + } }This includes migration support for legacy contacts, account-aware contact search, account-aware contact saving, macOS contact sync updates, and small generic collection helpers.
Commit 2: account cache cleanup
Adds a single
config.CleanupAccountCache(accountID)method that removes data associated with a deleted account from:email_cache.jsonfolder_cache.jsonfolder_emails/*.jsonemail_bodies/*.jsoncontacts.jsondrafts.jsonThe account deletion flow now calls this cleanup after
RemoveAccount.Why?
Closes: #519
Fixes stale account data being left behind after deleting an account.
Previously, deleting an account removed it from config and deleted credentials from the keyring, but cached emails, cached bodies, drafts, folder cache entries, and contact usage stayed on disk. Over time this left orphaned data in
~/.cache/matcha.The contact schema change makes it possible to remove only the deleted account’s contact association while preserving shared contacts still used by other accounts.