1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00
This commit is contained in:
carbotaniuman 2021-02-17 22:27:25 -06:00
parent 187b089946
commit 69357c4173
3 changed files with 62 additions and 2 deletions

View file

@ -48,6 +48,7 @@ dependencies {
implementation group: 'com.zaxxer', name: 'HikariCP', version: '4.0.1'
implementation group: "com.h2database", name: "h2", version: "1.4.200"
implementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.34.0'
implementation "org.ktorm:ktorm-core:$ktorm_version"
implementation "org.ktorm:ktorm-jackson:$ktorm_version"

View file

@ -65,9 +65,11 @@ class MangaDexClient(private val settingsFile: File, databaseFolder: Path, cache
LOGGER.info { "Client settings loaded: $settings" }
Class.forName("org.sqlite.JDBC")
val config = HikariConfig()
val db = databaseFolder.resolve("metadata")
config.jdbcUrl = "jdbc:h2:$db"
val db = databaseFolder.resolve("metadata.db")
config.jdbcUrl = "jdbc:sqlite:$db"
config.addDataSourceProperty("cachePrepStmts", "true")
config.addDataSourceProperty("prepStmtCacheSize", "100")
config.addDataSourceProperty("prepStmtCacheSqlLimit", "1000")

View file

@ -0,0 +1,57 @@
/*
Mangadex@Home
Copyright (c) 2020, MangaDex Network
This file is part of MangaDex@Home.
MangaDex@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MangaDex@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
*/
package mdnet
import mdnet.cache.DbImage
import mdnet.cache.INIT_TABLE
import org.ktorm.database.Database
import org.ktorm.dsl.*
import java.nio.file.Paths
fun main() {
Class.forName("org.sqlite.JDBC")
val sqliteDb = Paths.get("./metadata.db")
val sqlite = Database.connect("jdbc:sqlite:$sqliteDb")
sqlite.useConnection { conn ->
conn.prepareStatement(INIT_TABLE).use {
it.execute()
}
}
val db = Paths.get("./metadata")
val h2 = Database.connect("jdbc:h2:$db")
h2.useConnection { conn ->
conn.prepareStatement(INIT_TABLE).use {
it.execute()
}
}
sqlite.batchInsert(DbImage) {
h2.from(DbImage).select().forEach { data ->
item {
set(DbImage.id, data[DbImage.id])
set(DbImage.accessed, data[DbImage.accessed])
set(DbImage.size, data[DbImage.size])
}
}
}
}