feat: add method to clear free database pages - #2477
Conversation
After a clearCache() the database file actually does not shrink in size but has empty pages. Without the auto vacuum pragma it can never really shrink. This adds an optional method the sdk consumer can call to fix it.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c09061c. Configure here.
| return; | ||
| } | ||
|
|
||
| await database.execute('PRAGMA incremental_vacuum'); |
There was a problem hiding this comment.
Vacuum pragmas use execute incorrectly
Medium Severity
ensureIncrementalAutoVacuum runs VACUUM and PRAGMA incremental_vacuum through execute. Incremental vacuum yields one SQLITE_ROW per reclaimed page, so plugin-backed execute/execSQL (including sqflite_sqlcipher) either throws or stops after a single page. After the first mode-switch, the documented every-start / post-clearCache() path then fails to shrink the file.
Reviewed by Cursor Bugbot for commit c09061c. Configure here.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2477 +/- ##
==========================================
- Coverage 60.38% 60.36% -0.03%
==========================================
Files 162 162
Lines 20564 20572 +8
==========================================
Hits 12418 12418
- Misses 8146 8154 +8
Continue to review full report in Codecov by Harness.
|


After a clearCache() the database file actually does not shrink in size but has empty pages. Without the auto vacuum pragma it can never really shrink. This adds an optional method the sdk consumer can call to fix it.