Potentially fix 'database is locked' crash
This commit is contained in:
@@ -13,6 +13,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix app crashing when trying to add extension repo with existing signature ([@AntsyLich](https://github.com/AntsyLich))
|
- Fix app crashing when trying to add extension repo with existing signature ([@AntsyLich](https://github.com/AntsyLich))
|
||||||
|
- Potentially fix 'database is locked' crash ([@AntsyLich](https://github.com/AntsyLich))
|
||||||
|
|
||||||
## [v0.19.5] - 2026-03-20
|
## [v0.19.5] - 2026-03-20
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import app.cash.sqldelight.db.SqlDriver
|
|||||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteConfiguration
|
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteConfiguration
|
||||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDatabaseType
|
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDatabaseType
|
||||||
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDriver
|
import com.eygraber.sqldelight.androidx.driver.AndroidxSqliteDriver
|
||||||
import com.eygraber.sqldelight.androidx.driver.File
|
|
||||||
import com.eygraber.sqldelight.androidx.driver.FileProvider
|
import com.eygraber.sqldelight.androidx.driver.FileProvider
|
||||||
import eu.kanade.domain.track.store.DelayedTrackingStore
|
import eu.kanade.domain.track.store.DelayedTrackingStore
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
@@ -44,21 +43,31 @@ import uy.kohesive.injekt.api.InjektRegistrar
|
|||||||
import uy.kohesive.injekt.api.addSingleton
|
import uy.kohesive.injekt.api.addSingleton
|
||||||
import uy.kohesive.injekt.api.addSingletonFactory
|
import uy.kohesive.injekt.api.addSingletonFactory
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
|
private val lock = Any()
|
||||||
|
|
||||||
class AppModule(val app: Application) : InjektModule {
|
class AppModule(val app: Application) : InjektModule {
|
||||||
|
|
||||||
|
private var sqlDriverRef: WeakReference<SqlDriver>? = null
|
||||||
|
|
||||||
override fun InjektRegistrar.registerInjectables() {
|
override fun InjektRegistrar.registerInjectables() {
|
||||||
addSingleton(app)
|
addSingleton(app)
|
||||||
|
|
||||||
addSingletonFactory<SqlDriver> {
|
addSingletonFactory<SqlDriver> {
|
||||||
AndroidxSqliteDriver(
|
synchronized(lock) {
|
||||||
driver = BundledSQLiteDriver(),
|
sqlDriverRef?.get()?.let { return@synchronized it }
|
||||||
databaseType = AndroidxSqliteDatabaseType.FileProvider(app, "tachiyomi.db"),
|
|
||||||
schema = Database.Schema,
|
AndroidxSqliteDriver(
|
||||||
configuration = AndroidxSqliteConfiguration(
|
driver = BundledSQLiteDriver(),
|
||||||
isForeignKeyConstraintsEnabled = true,
|
databaseType = AndroidxSqliteDatabaseType.FileProvider(app, "tachiyomi.db"),
|
||||||
),
|
schema = Database.Schema,
|
||||||
)
|
configuration = AndroidxSqliteConfiguration(
|
||||||
|
isForeignKeyConstraintsEnabled = true,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.also { sqlDriverRef = WeakReference(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addSingletonFactory {
|
addSingletonFactory {
|
||||||
Database(
|
Database(
|
||||||
|
|||||||
Reference in New Issue
Block a user