From b2d5354798355008aa922e3c77632480ab52261c Mon Sep 17 00:00:00 2001 From: Syer10 Date: Sat, 3 Apr 2021 17:25:53 -0400 Subject: [PATCH] dirs -> applicationDirs --- .../main/kotlin/ir/armor/tachidesk/impl/Extension.kt | 10 +++++----- .../src/main/kotlin/ir/armor/tachidesk/impl/Manga.kt | 4 ++-- server/src/main/kotlin/ir/armor/tachidesk/impl/Page.kt | 4 ++-- .../ir/armor/tachidesk/impl/util/GetHttpSource.kt | 4 ++-- .../ir/armor/tachidesk/impl/util/PackageTools.kt | 4 ++-- .../ir/armor/tachidesk/model/dataclass/DBMangaer.kt | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt index b90bb6d..3adef0b 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt @@ -48,7 +48,7 @@ import java.io.InputStream object Extension { private val logger = KotlinLogging.logger {} - private val dirs by DI.global.instance() + private val applicationDirs by DI.global.instance() data class InstallableAPK( @@ -63,7 +63,7 @@ object Extension { return installAPK { val apkURL = ExtensionGithubApi.getApkUrl(extensionRecord) val apkName = Uri.parse(apkURL).lastPathSegment!! - val apkSavePath = "${dirs.extensionsRoot}/$apkName" + val apkSavePath = "${applicationDirs.extensionsRoot}/$apkName" // download apk file downloadAPKFile(apkURL, apkSavePath) @@ -84,7 +84,7 @@ object Extension { if (!isInstalled) { val fileNameWithoutType = apkName.substringBefore(".apk") - val dirPathWithoutType = "${dirs.extensionsRoot}/$fileNameWithoutType" + val dirPathWithoutType = "${applicationDirs.extensionsRoot}/$fileNameWithoutType" val jarFilePath = "$dirPathWithoutType.jar" val dexFilePath = "$dirPathWithoutType.dex" @@ -198,7 +198,7 @@ object Extension { val extensionRecord = transaction { ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.firstOrNull()!! } val fileNameWithoutType = extensionRecord[ExtensionTable.apkName].substringBefore(".apk") - val jarPath = "${dirs.extensionsRoot}/$fileNameWithoutType.jar" + val jarPath = "${applicationDirs.extensionsRoot}/$fileNameWithoutType.jar" transaction { val extensionId = extensionRecord[ExtensionTable.id].value @@ -237,7 +237,7 @@ object Extension { suspend fun getExtensionIcon(apkName: String): Pair { val iconUrl = transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.firstOrNull()!! }[ExtensionTable.iconUrl] - val saveDir = "${dirs.extensionsRoot}/icon" + val saveDir = "${applicationDirs.extensionsRoot}/icon" return getCachedImageResponse(saveDir, apkName) { network.client.newCall( diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/Manga.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/Manga.kt index 09a41ca..4e3071b 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/Manga.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/Manga.kt @@ -98,10 +98,10 @@ object Manga { } } - private val dirs by DI.global.instance() + private val applicationDirs by DI.global.instance() suspend fun getMangaThumbnail(mangaId: Int): Pair { val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!! } - val saveDir = dirs.thumbnailsRoot + val saveDir = applicationDirs.thumbnailsRoot val fileName = mangaId.toString() return getCachedImageResponse(saveDir, fileName) { diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/Page.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/Page.kt index d8c0db4..299ad8f 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/Page.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/Page.kt @@ -76,7 +76,7 @@ object Page { } // TODO: rewrite this to match tachiyomi - private val dirs by DI.global.instance() + private val applicationDirs by DI.global.instance() fun getChapterDir(mangaId: Int, chapterId: Int): String { val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!! } val sourceId = mangaEntry[MangaTable.sourceReference] @@ -92,7 +92,7 @@ object Page { val mangaTitle = mangaEntry[MangaTable.title] val sourceName = source.toString() - val mangaDir = "${dirs.mangaRoot}/$sourceName/$mangaTitle/$chapterDir" + val mangaDir = "${applicationDirs.mangaRoot}/$sourceName/$mangaTitle/$chapterDir" // make sure dirs exist File(mangaDir).mkdirs() return mangaDir diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt index 62c6b0f..0c01ea9 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt @@ -23,7 +23,7 @@ import java.util.concurrent.ConcurrentHashMap object GetHttpSource { private val sourceCache = ConcurrentHashMap() - private val dirs by DI.global.instance() + private val applicationDirs by DI.global.instance() fun getHttpSource(sourceId: Long): HttpSource { val cachedResult: HttpSource? = sourceCache[sourceId] @@ -43,7 +43,7 @@ object GetHttpSource { val apkName = extensionRecord[ExtensionTable.apkName] val className = extensionRecord[ExtensionTable.classFQName] val jarName = apkName.substringBefore(".apk") + ".jar" - val jarPath = "${dirs.extensionsRoot}/$jarName" + val jarPath = "${applicationDirs.extensionsRoot}/$jarName" when (val instance = loadExtensionSources(jarPath, className)) { is Source -> listOf(instance) diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/PackageTools.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/PackageTools.kt index 3b989b6..44ea565 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/PackageTools.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/PackageTools.kt @@ -34,7 +34,7 @@ import javax.xml.parsers.DocumentBuilderFactory object PackageTools { private val logger = KotlinLogging.logger {} - private val dirs by DI.global.instance() + private val applicationDirs by DI.global.instance() const val EXTENSION_FEATURE = "tachiyomi.extension" const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class" @@ -69,7 +69,7 @@ object PackageTools { .skipExceptions(false) .to(jarFilePath) if (handler.hasException()) { - val errorFile: Path = File(dirs.extensionsRoot).toPath().resolve("$fileNameWithoutType-error.txt") + val errorFile: Path = File(applicationDirs.extensionsRoot).toPath().resolve("$fileNameWithoutType-error.txt") logger.error( "Detail Error Information in File $errorFile\n" + "Please report this file to one of following link if possible (any one).\n" + diff --git a/server/src/main/kotlin/ir/armor/tachidesk/model/dataclass/DBMangaer.kt b/server/src/main/kotlin/ir/armor/tachidesk/model/dataclass/DBMangaer.kt index 1255d2f..2d5c1f7 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/model/dataclass/DBMangaer.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/model/dataclass/DBMangaer.kt @@ -24,8 +24,8 @@ import org.kodein.di.instance object DBMangaer { val db by lazy { - val dirs by DI.global.instance() - Database.connect("jdbc:h2:${dirs.dataRoot}/database", "org.h2.Driver") + val applicationDirs by DI.global.instance() + Database.connect("jdbc:h2:${applicationDirs.dataRoot}/database", "org.h2.Driver") } }