Repository navigation
fix(media): cap the media disk cache at 256 MiB - #230
Merged
Merged
Conversation
The media reference disk cache (Caches/media-references) only ever grew. Port iOS #299 (011ee6bd): the disk tier holds at most 256 MiB. A write that takes it past the budget deletes the least recently used blobs, by modification date, until a quarter is free, never the blob just written. A disk read touches the file so it counts as a use. The total is counted once from file metadata and then kept by writes. Ports iOS test theDiskTierTrimsLeastRecentlyUsedBlobsPastItsBudget into MediaReferenceTests; it fails without the trim. Verified: vm.sh check :feature:media, full vm.sh check (both green). Not visible, so no emulator check.
Review fixes for the disk cap: - The sweep counts and deletes only .blob files, so another load's in-flight .partial is never charged or deleted before its rename. - The rename and its accounting run under the disk lock, and a blob that replaces one already on disk is charged only the difference. - Each blob's size and modification date are read once, then sorted, so a concurrent touch can't break the sort. - One scan counts and trims, and it trims only when the real total is over 256 MiB, so a stale count after the system clears the cache doesn't evict. - load() no longer reads the disk itself; resolve() already does that on the IO dispatcher, so the new touch never runs on the main thread. The touch is best effort. - The test backdates modification dates instead of sleeping, and checks an in-flight partial survives (fails without the .blob filter). Verified: vm.sh check :feature:media and full vm.sh check (green).
Tarquinen
enabled auto-merge (squash)
November 22, 2026 18:16
CrashedSystem
added a commit
to CrashedSystem/opencode-android
that referenced
this pull request
Nov 23, 2026
Upstream moved from d442dea (2026-11-21) to fc35d8f (2026-11-22). Merged with no conflicts; every fork change survives (verified by grepping each: forkDebug signing, RELAY_URL, session vibration, Firebase resources, Korean copy, the Android home in AgentFileReference). Upstream's seven: - fc35d8f fix(app): stop WorkManager crashing at start while the user is locked (anomalyco#284) - 1563fa5 perf(voice): run raise to talk motion only while the sensor is covered (anomalyco#231) - 43defc2 fix(media): cap the media disk cache at 256 MiB (anomalyco#230) - fad0873 fix(server): stop encoding an oversized transcript cache entry whole (anomalyco#285) - fe3e324 fix(core): skip encoding in-memory shared keys (anomalyco#258) - 2356197 fix(app): keep OkHttp's IDN table out of the hostname method (anomalyco#262) - 67198a9 fix(transcript): merge inline runs in linear time (anomalyco#283)
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.
The media disk cache now stays under 256 MiB instead of growing forever. When a write goes past the limit, the least recently used images are deleted until a quarter of the space is free; reading an image from disk counts as using it.
Ports iOS #299 (011ee6bd), the disk cap part only (thumbnail decoding is a separate PR).
Verification
theDiskTierTrimsLeastRecentlyUsedBlobsPastItsBudget; it fails without the trim and passes with it.scripts/check.shgreen on the Android VM.Nothing visible changes, so no media.