fix(clean): report sub-megabyte Service Worker cleanups in KB - #1229
Merged
tw93 merged 2 commits intoJul 17, 2026
Conversation
…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.
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.
Summary
clean_service_worker_cachereported any cleanup under 1 MB as0MB.cleaned_size / 1024integer division, which truncates anything below 1024 KB to0. Service WorkerCacheStoragefolders are per-origin and often only a few hundred KB, so this was easy to hit.bytes_to_humanformatter — 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.2MBinstead of5MB), making this row consistent with the rest of Mole's output.Safety Review
Tests
bats tests/clean_system_caches.bats— addedclean_service_worker_cache reports sub-megabyte cleanups as KB, not 0MB(feeds a 900 KB cleanup and asserts the row showsKB, never0MB). Updated the existing color test's expectation from1MBto1.0MBto match the shared formatter. The rest of the Service Worker tests pass unchanged.shellcheck lib/clean/caches.shandshfmt -i 4 -ci -sr -d lib/clean/caches.share clean.Safety-related changes