Skip to content

fix(browser): safely clean up IdsFile - #22283

Merged
mikehardy merged 2 commits into
ankidroid:mainfrom
david-allison:19572-10
Oct 4, 2026
Merged

mikehardy merged 2 commits into
ankidroid:mainfrom
david-allison:19572-10

Conversation

@david-allison

Copy link
Copy Markdown
Member

Note

Assisted-by: GPT-6

Purpose / Description

This is a special-case, where we modify the IdsFile inside the class as state, rather than just passing it as an argument, so it needs a little more delicate handling.

Fixes

Approach

  • Delete only after the replacement is written
  • Delete the final snapshot via onPermanentDismissal

How Has This Been Tested?

Tests added

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

This is very heavily documented as there are subtle issues, such as
`ViewModel.onCleared` not necessarily being a permanent dismissal.

As part of our IdsFile changes, where we want to keep a file on disk
and reference this in our activity state, but also allow multiple
concurrent files on disk in case an activity exists twice in the task
graph.

Part of 19572

Assisted-by: GPT-6
* Delete only after the replacement is written
* Delete the final snapshot via `onPermanentDismissal`

Part of 19572

Assisted-by: Claude Fable 5.1
Assisted-by: GPT-6

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey David 👋

Thanks for documenting why onCleared is the wrong cleanup hook here. I walked the CardBrowser save/restore path: the replacement IdsFile is written before the previous snapshot is deleted, and onPermanentDismissal only runs when isFinishing, so rotation / "Don't keep activities" still leave the file for restore. The tests pin that, including the missing-cacheDir write failure.

This is correctly Part of #19572 — process-death cache eviction can still ENOENT, and that path is still caught and silent-reported.

LGTM

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Review labels Oct 4, 2026
@mikehardy
mikehardy added this pull request to the merge queue Oct 4, 2026
Merged via the queue into ankidroid:main with commit 47f354c Oct 4, 2026
27 of 30 checks passed
@github-actions github-actions Bot added this to the 2.26 release milestone Oct 4, 2026
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Oct 4, 2026
@david-allison
david-allison deleted the 19572-10 branch October 4, 2026 19:36
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