VACUUM exists to reclaim free pages, so we vacuum exactly when there are enough of them. It’s self-limiting — a freshly vacuumed db has ~0 free pages, so it won’t re-trigger until expiry deletes accumulate again — and needs no persisted “last vacuumed” state.
comicbox.formats.base.online.vacuum¶
source module comicbox.formats.base.online.vacuum
Conditional SQLite VACUUM for the online caches.
mokkari and simyan both delete expired rows when their cache opens, but neither ever VACUUMs — a DELETE only moves pages onto the free list, it doesn’t return them to the OS, so the file keeps its high-water-mark size. This reclaims that space, but only when there’s enough of it to justify rewriting the whole file.
The trigger is the free-page ratio, not the calendar or the raw file size
Functions
-
vacuum_if_bloated — VACUUM a sqlite cache only when reclaimable space is worth it.
source vacuum_if_bloated(db_path: Path | str) → bool
VACUUM a sqlite cache only when reclaimable space is worth it.
Returns True if a VACUUM ran. A cheap no-op (one PRAGMA pair, or less) for missing, small, or already-compact files. Best-effort housekeeping: a locked/busy db is skipped rather than allowed to fail a lookup.