mirror of
https://github.com/gotson/komga.git
synced 2025-01-09 04:08:00 +08:00
fix: expose configuration for transaction mode
This commit is contained in:
parent
ce8f80e6ee
commit
218e3006f9
@ -4,6 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.boot.convert.DurationUnit
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.validation.annotation.Validated
|
||||
import org.sqlite.SQLiteConfig.TransactionMode
|
||||
import java.time.Duration
|
||||
import java.time.temporal.ChronoUnit
|
||||
import javax.validation.constraints.NotBlank
|
||||
@ -73,6 +74,8 @@ class KomgaProperties {
|
||||
|
||||
@get:Positive
|
||||
var maxPoolSize: Int = 8
|
||||
|
||||
var transactionMode: TransactionMode = TransactionMode.DEFERRED
|
||||
}
|
||||
|
||||
class Lucene {
|
||||
|
@ -20,10 +20,13 @@ class DataSourcesConfiguration(
|
||||
|
||||
val sqliteUdfDataSource = DataSourceBuilder.create()
|
||||
.driverClassName("org.sqlite.JDBC")
|
||||
.url("jdbc:sqlite:${komgaProperties.database.file}?foreign_keys=on;")
|
||||
.url("jdbc:sqlite:${komgaProperties.database.file}")
|
||||
.type(SqliteUdfDataSource::class.java)
|
||||
.build()
|
||||
|
||||
sqliteUdfDataSource.setEnforceForeignKeys(true)
|
||||
sqliteUdfDataSource.setTransactionMode(komgaProperties.database.transactionMode.name)
|
||||
|
||||
val poolSize =
|
||||
if (komgaProperties.database.file.contains(":memory:")) 1
|
||||
else Runtime.getRuntime().availableProcessors().coerceAtMost(komgaProperties.database.maxPoolSize)
|
||||
|
@ -3,15 +3,15 @@ package org.gotson.komga.infrastructure.datasource
|
||||
import com.ibm.icu.text.Collator
|
||||
import mu.KotlinLogging
|
||||
import org.gotson.komga.language.stripAccents
|
||||
import org.springframework.jdbc.datasource.SimpleDriverDataSource
|
||||
import org.sqlite.Collation
|
||||
import org.sqlite.Function
|
||||
import org.sqlite.SQLiteConnection
|
||||
import org.sqlite.SQLiteDataSource
|
||||
import java.sql.Connection
|
||||
|
||||
private val log = KotlinLogging.logger {}
|
||||
|
||||
class SqliteUdfDataSource : SimpleDriverDataSource() {
|
||||
class SqliteUdfDataSource : SQLiteDataSource() {
|
||||
|
||||
companion object {
|
||||
const val udfStripAccents = "UDF_STRIP_ACCENTS"
|
||||
@ -21,8 +21,8 @@ class SqliteUdfDataSource : SimpleDriverDataSource() {
|
||||
override fun getConnection(): Connection =
|
||||
super.getConnection().also { addAllUdf(it as SQLiteConnection) }
|
||||
|
||||
override fun getConnection(username: String, password: String): Connection =
|
||||
super.getConnection(username, password).also { addAllUdf(it as SQLiteConnection) }
|
||||
override fun getConnection(username: String?, password: String?): SQLiteConnection =
|
||||
super.getConnection(username, password).also { addAllUdf(it) }
|
||||
|
||||
private fun addAllUdf(connection: SQLiteConnection) {
|
||||
createUdfRegexp(connection)
|
||||
|
Loading…
Reference in New Issue
Block a user