From 71a9396952e03e6390627cab38ac939dd16c9902 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Tue, 30 Mar 2021 01:18:57 +0430 Subject: [PATCH] starts of legacy backup support --- .gitignore | 1 + .../extension/api/ExtensionGithubApi.kt | 6 ++---- .../ir/armor/tachidesk/impl/ExtensionsList.kt | 3 ++- .../ir/armor/tachidesk/server/JavalinSetup.kt | 19 +++++++++++++++++++ .../ir/armor/tachidesk/server/ServerSetup.kt | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 823d2ca..7e3ffdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore Gradle project-specific cache directory .gradle .idea +gradle.properties # Ignore Gradle build output directory build diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt index 9d0cfad..423e357 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt @@ -85,9 +85,7 @@ internal class ExtensionGithubApi { } companion object { -// const val BASE_URL = "https://raw.githubusercontent.com" -// const val REPO_URL_PREFIX = "${BASE_URL}/tachiyomiorg/tachiyomi-extensions/repo" - const val BASE_URL = "http://127.0.0.1:8000" - const val REPO_URL_PREFIX = "$BASE_URL/repo" + const val BASE_URL = "https://raw.githubusercontent.com" + const val REPO_URL_PREFIX = "$BASE_URL/tachiyomiorg/tachiyomi-extensions/repo" } } diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/ExtensionsList.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/ExtensionsList.kt index 0a34ad5..2c84af0 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/ExtensionsList.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/ExtensionsList.kt @@ -28,7 +28,8 @@ object ExtensionListData { var updateMap = ConcurrentHashMap() } -const val ExtensionUpdateDelayTime = 0 // 60 seconds +// const val ExtensionUpdateDelayTime = 60 * 1000 // 60,000 milliseconds = 60 seconds +const val ExtensionUpdateDelayTime = 0 fun getExtensionList(): List { // update if {ExtensionUpdateDelayTime} seconds has passed or requested offline and database is empty diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt index 12d45d5..1d0b60a 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt @@ -32,6 +32,7 @@ import ir.armor.tachidesk.impl.updateCategory import ir.armor.tachidesk.impl.updateExtension import ir.armor.tachidesk.server.util.openInBrowser import mu.KotlinLogging +import java.io.IOException /* * Copyright (C) Contributors to the Suwayomi project @@ -66,6 +67,12 @@ fun javalinSetup() { ctx.status(404) } + app.exception(IOException::class.java) { e, ctx -> + logger.error("IOException while handling the request", e) + ctx.status(500) + ctx.result(e.message ?: "Internal Server Error") + } + app.get("/api/v1/extension/list") { ctx -> ctx.json(getExtensionList()) } @@ -266,4 +273,16 @@ fun javalinSetup() { val categoryId = ctx.pathParam("categoryId").toInt() ctx.json(getCategoryMangaList(categoryId)) } + + // expects a Tachiyomi legacy backup file to be uploaded + app.get("/api/v1/backup/legacy/import") { ctx -> + val categoryId = ctx.pathParam("categoryId").toInt() + ctx.json(getCategoryMangaList(categoryId)) + } + + // returns a Tachiyomi legacy backup file created from the current database + app.get("/api/v1/backup/legacy/export") { ctx -> + val categoryId = ctx.pathParam("categoryId").toInt() + ctx.json(getCategoryMangaList(categoryId)) + } } diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/ServerSetup.kt index 8cf173c..18bcc33 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/ServerSetup.kt @@ -96,7 +96,7 @@ fun applicationSetup() { // socks proxy settings if (serverConfig.socksProxyEnabled) { - System.getProperties()["proxySet"] = "true" +// System.getProperties()["proxySet"] = "true" System.getProperties()["socksProxyHost"] = serverConfig.socksProxyHost System.getProperties()["socksProxyPort"] = serverConfig.socksProxyPort logger.info("Socks Proxy is enabled to ${serverConfig.socksProxyHost}:${serverConfig.socksProxyPort}")