mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-08 09:42:55 +02:00
feat(db): VACUUM after retention and an Optimize button in Backup modal
SQLite DELETE marks pages free but doesn't shrink the file, so the new retention job would keep DBs at their bloated size forever without a follow-up VACUUM. Add db.vacuum() that runs PRAGMA-free VACUUM and reports size_before/size_after/elapsed so callers can surface results. The retention job now calls vacuum() automatically when it deleted at least 1000 rows. Threshold avoids the multi-second VACUUM cost on quiet days. Failure is logged, not raised — a missed VACUUM never crashes the scheduler. Power-user override: new "Optimize now" button in the Database Backup modal triggers VACUUM on demand via POST /api/db/vacuum, alongside a GET /api/db/size that drives the live "Current size" label. This way users don't have to wait until 03:30 to reclaim space after the first big retention pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1212,6 +1212,18 @@
|
||||
<div class="spinner-border spinner-border-sm"></div> Loading...
|
||||
</div>
|
||||
</div>
|
||||
<hr class="my-3">
|
||||
<h6 class="mb-2"><i class="bi bi-arrows-collapse"></i> Optimize database</h6>
|
||||
<p class="text-muted small mb-2">
|
||||
Reclaim space freed by message retention. Runs SQLite <code>VACUUM</code>;
|
||||
readers keep working but writes are paused for a few seconds.
|
||||
</p>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<button class="btn btn-outline-primary btn-sm" id="vacuumDbBtn" onclick="optimizeDatabase()">
|
||||
<i class="bi bi-arrows-collapse"></i> Optimize now
|
||||
</button>
|
||||
<span id="vacuumDbStatus" class="text-muted small">Current size: …</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user