mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-11 16:29:08 +01:00
Manga dir
This commit is contained in:
parent
9e308025c3
commit
172f83f5b3
@ -10,4 +10,5 @@ object Config {
|
||||
val dataRoot = AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)
|
||||
val extensionsRoot = "$dataRoot/extensions"
|
||||
val thumbnailsRoot = "$dataRoot/thumbnails"
|
||||
val mangaRoot = "$dataRoot/manga"
|
||||
}
|
||||
|
@ -10,9 +10,12 @@ import ir.armor.tachidesk.Config
|
||||
import ir.armor.tachidesk.database.dataclass.MangaDataClass
|
||||
import ir.armor.tachidesk.database.table.MangaStatus
|
||||
import ir.armor.tachidesk.database.table.MangaTable
|
||||
import ir.armor.tachidesk.database.table.SourceTable
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.util.concurrent.ArrayBlockingQueue
|
||||
|
||||
@ -128,8 +131,8 @@ fun getManga(mangaId: Int, proxyThumbnail: Boolean = true): MangaDataClass {
|
||||
|
||||
fun getThumbnail(mangaId: Int): Pair<InputStream, String> {
|
||||
return transaction {
|
||||
var filePath = Config.thumbnailsRoot + "/$mangaId"
|
||||
var mangaEntry = MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!!
|
||||
var filePath = Config.thumbnailsRoot + "/$mangaId"
|
||||
|
||||
val potentialCache = findFileNameStartingWith(Config.thumbnailsRoot, mangaId.toString())
|
||||
if (potentialCache != null) {
|
||||
@ -169,3 +172,17 @@ fun getThumbnail(mangaId: Int): Pair<InputStream, String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getMangaDir(mangaId: Int): String {
|
||||
val mangaEntry = MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!!
|
||||
val sourceId = mangaEntry[MangaTable.sourceReference].value
|
||||
val sourceEntry = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()!!
|
||||
|
||||
val mangaTitle = mangaEntry[MangaTable.title]
|
||||
val sourceName = sourceEntry[SourceTable.name]
|
||||
|
||||
val mangaDir = "${Config.mangaRoot}/$sourceName/$mangaTitle"
|
||||
// make sure dirs exist
|
||||
File(mangaDir).mkdirs()
|
||||
return mangaDir
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user