mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-29 15:28:48 +02:00
perf(db): enable incremental auto-vacuum so cleared data shrinks the file
This commit is contained in:
@@ -796,6 +796,11 @@ class HistoryDatabase {
|
||||
await txn.delete('history_path_keys');
|
||||
await txn.delete('history');
|
||||
});
|
||||
// Return freed pages to the OS (no-op unless the file was created with
|
||||
// auto_vacuum enabled).
|
||||
try {
|
||||
await db.execute('PRAGMA incremental_vacuum');
|
||||
} catch (_) {}
|
||||
_log.i('Cleared all history');
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ Future<Database> openAppDatabase(
|
||||
if (foreignKeys) {
|
||||
await db.execute('PRAGMA foreign_keys = ON');
|
||||
}
|
||||
// Without auto_vacuum the file never shrinks after deletes — its size
|
||||
// is a permanent high-water mark. Only takes effect on newly created
|
||||
// databases; existing files keep their mode until a manual VACUUM.
|
||||
await db.execute('PRAGMA auto_vacuum = INCREMENTAL');
|
||||
await db.rawQuery('PRAGMA journal_mode = WAL');
|
||||
await db.execute('PRAGMA synchronous = NORMAL');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user