mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-02 04:33:52 -04:00
DB: Force a wal_checkpoint after every repo update to keep the wal file small (fixes #2588)
This commit is contained in:
@@ -8,10 +8,20 @@ import androidx.room.Insert
|
||||
import androidx.room.MapInfo
|
||||
import androidx.room.OnConflictStrategy.Companion.REPLACE
|
||||
import androidx.room.Query
|
||||
import androidx.room.RawQuery
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import androidx.sqlite.db.SupportSQLiteQuery
|
||||
|
||||
public interface AppPrefsDao {
|
||||
public fun getAppPrefs(packageName: String): LiveData<AppPrefs>
|
||||
public fun update(appPrefs: AppPrefs)
|
||||
|
||||
/**
|
||||
* Force a checkpoint on the SQLite WAL such that the file size gets reduced.
|
||||
* Blocks until concurrent reads have finished.
|
||||
* Useful to call after large inserts (repo update)
|
||||
*/
|
||||
public fun walCheckpoint()
|
||||
}
|
||||
|
||||
@Dao
|
||||
@@ -48,4 +58,12 @@ internal interface AppPrefsDaoInt : AppPrefsDao {
|
||||
|
||||
@Insert(onConflict = REPLACE)
|
||||
override fun update(appPrefs: AppPrefs)
|
||||
|
||||
override fun walCheckpoint() {
|
||||
rawCheckpoint((SimpleSQLiteQuery("pragma wal_checkpoint(truncate)")))
|
||||
}
|
||||
|
||||
@RawQuery
|
||||
fun rawCheckpoint(supportSQLiteQuery: SupportSQLiteQuery): Int
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user