Skip to content

fix(clean): report sub-megabyte Service Worker cleanups in KB - #1229

Merged
tw93 merged 2 commits into
tw93:mainfrom
LuisMIguelFurlanettoSousa:fix/service-worker-sub-mb
Jul 17, 2026
Merged

fix(clean): report sub-megabyte Service Worker cleanups in KB#1229
tw93 merged 2 commits into
tw93:mainfrom
LuisMIguelFurlanettoSousa:fix/service-worker-sub-mb

Conversation

@LuisMIguelFurlanettoSousa

Copy link
Copy Markdown
Contributor

Summary

  • Fixes [BUG] Service Worker cleanup under 1MB is reported as "0MB" #1228. clean_service_worker_cache reported any cleanup under 1 MB as 0MB.
  • It tracked the cleaned amount in KB and formatted it with a hand-rolled cleaned_size / 1024 integer division, which truncates anything below 1024 KB to 0. Service Worker CacheStorage folders are per-origin and often only a few hundred KB, so this was easy to hit.
  • Switch to the shared bytes_to_human formatter — the same one every other cleaner uses — so sub-MB amounts render as KB (e.g. 922KB). MB amounts now carry the standard one-decimal format used elsewhere (e.g. 5.2MB instead of 5MB), making this row consistent with the rest of Mole's output.

Safety Review

  • No. This only changes how the freed size is formatted for display; the scan, protection, whitelist, and removal logic are untouched.

Tests

  • bats tests/clean_system_caches.bats — added clean_service_worker_cache reports sub-megabyte cleanups as KB, not 0MB (feeds a 900 KB cleanup and asserts the row shows KB, never 0MB). Updated the existing color test's expectation from 1MB to 1.0MB to match the shared formatter. The rest of the Service Worker tests pass unchanged.
  • shellcheck lib/clean/caches.sh and shfmt -i 4 -ci -sr -d lib/clean/caches.sh are clean.

Safety-related changes

  • None.

…ass vacuously

Bare [[ ]] assertion failures mid-test can be swallowed (same shape as
tw93#886), and the trailing rm -rf returned 0, so the regression test passed
even against the pre-fix truncation. Verified after hardening: fails on
the pre-fix lib/clean/caches.sh, passes with the fix.
@tw93
tw93 merged commit 4067648 into tw93:main Jul 17, 2026
9 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.

[BUG] Service Worker cleanup under 1MB is reported as "0MB"

2 participants