mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-05-02 04:33:52 -04:00
Move walCheckpoint to RepositoryDao
This commit is contained in:
@@ -8,20 +8,10 @@ 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
|
||||
@@ -59,11 +49,4 @@ 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
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy.Companion.REPLACE
|
||||
import androidx.room.Query
|
||||
import androidx.room.RawQuery
|
||||
import androidx.room.RewriteQueriesToDropUnusedColumns
|
||||
import androidx.room.Transaction
|
||||
import androidx.room.Update
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import androidx.sqlite.db.SupportSQLiteQuery
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
import org.fdroid.database.DbDiffUtils.diffAndUpdateListTable
|
||||
@@ -87,6 +90,13 @@ public interface RepositoryDao {
|
||||
* Removes all repos and their preferences.
|
||||
*/
|
||||
public fun clearAll()
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -527,4 +537,10 @@ internal interface RepositoryDaoInt : RepositoryDao {
|
||||
@Query("SELECT COUNT(*) FROM ${ReleaseChannel.TABLE}")
|
||||
fun countReleaseChannels(): Int
|
||||
|
||||
override fun walCheckpoint() {
|
||||
rawCheckpoint((SimpleSQLiteQuery("pragma wal_checkpoint(truncate)")))
|
||||
}
|
||||
|
||||
@RawQuery
|
||||
fun rawCheckpoint(supportSQLiteQuery: SupportSQLiteQuery): Int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user