From 73dacc6a07eabc0fcce8463c58f9dea0fe998ba5 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Fri, 21 Oct 2022 17:33:09 -0400 Subject: [PATCH 1/2] Update dependencies and lint files --- AndroidCompat/build.gradle.kts | 8 ++--- .../src/main/java/android/text/Html.java | 4 +-- .../androidcompat/db/ScrollableResultSet.kt | 28 +++++++++++----- .../io/sharedprefs/JavaSharedPreferences.kt | 6 ++-- .../androidcompat/pm/PackageController.kt | 5 +-- build.gradle.kts | 33 +++++++++---------- buildSrc/src/main/kotlin/Constants.kt | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- server/build.gradle.kts | 25 +++++++------- .../kotlin/eu/kanade/tachiyomi/AppModule.kt | 1 - .../interceptor/RateLimitInterceptor.kt | 4 +-- .../SpecificHostRateLimitInterceptor.kt | 4 +-- .../tachiyomi/source/local/LocalSource.kt | 3 +- .../kanade/tachiyomi/util/storage/EpubFile.kt | 2 +- .../suwayomi/tachidesk/global/impl/About.kt | 4 +-- .../tachidesk/global/impl/AppUpdate.kt | 6 ++-- .../manga/controller/BackupController.kt | 4 +-- .../suwayomi/tachidesk/manga/impl/Category.kt | 4 ++- .../tachidesk/manga/impl/CategoryManga.kt | 3 +- .../suwayomi/tachidesk/manga/impl/Chapter.kt | 4 ++- .../suwayomi/tachidesk/manga/impl/Manga.kt | 12 ++++--- .../suwayomi/tachidesk/manga/impl/Search.kt | 2 +- .../suwayomi/tachidesk/manga/impl/Source.kt | 2 +- .../manga/impl/backup/BackupFlags.kt | 2 +- .../impl/backup/proto/ProtoBackupExport.kt | 6 ++-- .../manga/impl/backup/proto/models/Backup.kt | 2 +- .../backup/proto/models/BackupCategory.kt | 2 +- .../impl/backup/proto/models/BackupChapter.kt | 2 +- .../impl/backup/proto/models/BackupManga.kt | 2 +- .../backup/proto/models/BackupTracking.kt | 2 +- .../manga/impl/chapter/ChapterForDownload.kt | 1 - .../manga/impl/download/DownloadManager.kt | 15 ++++++--- .../impl/download/model/DownloadChapter.kt | 2 +- .../impl/download/model/DownloadState.kt | 2 +- .../impl/download/model/DownloadStatus.kt | 2 +- .../manga/impl/extension/Extension.kt | 12 ++++--- .../manga/impl/extension/ExtensionsList.kt | 2 +- .../extension/github/ExtensionGithubApi.kt | 2 +- .../manga/impl/update/UpdaterSocket.kt | 3 +- .../manga/impl/util/BytecodeEditor.kt | 10 ++++-- .../tachidesk/manga/impl/util/DirName.kt | 6 ++-- .../manga/impl/util/lang/RxCoroutineBridge.kt | 12 ++++--- .../manga/impl/util/storage/ImageResponse.kt | 3 +- .../manga/model/dataclass/ChapterDataClass.kt | 2 +- .../model/dataclass/ExtensionDataClass.kt | 2 +- .../model/dataclass/MangaChapterDataClass.kt | 2 +- .../manga/model/dataclass/PageDataClass.kt | 2 +- .../manga/model/dataclass/PaginatedList.kt | 2 +- .../manga/model/dataclass/SourceDataClass.kt | 2 +- .../manga/model/table/CategoryTable.kt | 2 +- .../manga/model/table/ChapterTable.kt | 2 +- .../tachidesk/manga/model/table/MangaTable.kt | 2 +- .../suwayomi/tachidesk/server/ServerSetup.kt | 2 +- .../database/migration/M0001_Initial.kt | 4 +-- .../M0011_SourceDropPartOfFactorySource.kt | 2 +- .../tachidesk/server/util/DocumentationDsl.kt | 16 ++++----- .../server/util/WebInterfaceManager.kt | 3 +- .../tachidesk/manga/impl/CategoryMangaTest.kt | 15 ++++++--- .../tachidesk/manga/impl/MangaTest.kt | 9 +++-- .../tachidesk/manga/impl/SearchTest.kt | 7 ++-- .../manga/model/PaginatedListTest.kt | 16 ++++----- .../tachidesk/test/ApplicationTest.kt | 2 +- .../suwayomi/tachidesk/test/TestUtils.kt | 4 ++- 63 files changed, 204 insertions(+), 152 deletions(-) diff --git a/AndroidCompat/build.gradle.kts b/AndroidCompat/build.gradle.kts index b14a6d77b..50a3a6a5f 100644 --- a/AndroidCompat/build.gradle.kts +++ b/AndroidCompat/build.gradle.kts @@ -9,20 +9,20 @@ dependencies { implementation(project(":AndroidCompat:Config")) // APK sig verifier - compileOnly("com.android.tools.build:apksig:7.1.0-beta05") + compileOnly("com.android.tools.build:apksig:7.2.1") // AndroidX annotations - compileOnly("androidx.annotation:annotation:1.3.0") + compileOnly("androidx.annotation:annotation:1.5.0") // substitute for duktape-android implementation("org.mozilla:rhino-runtime:1.7.14") // slimmer version of 'org.mozilla:rhino' implementation("org.mozilla:rhino-engine:1.7.14") // provides the same interface as 'javax.script' a.k.a Nashorn // Kotlin wrapper around Java Preferences, makes certain things easier - val multiplatformSettingsVersion = "0.8.1" + val multiplatformSettingsVersion = "1.0.0-RC" implementation("com.russhwolf:multiplatform-settings-jvm:$multiplatformSettingsVersion") implementation("com.russhwolf:multiplatform-settings-serialization-jvm:$multiplatformSettingsVersion") // Android version of SimpleDateFormat - implementation("com.ibm.icu:icu4j:70.1") + implementation("com.ibm.icu:icu4j:72.1") } diff --git a/AndroidCompat/src/main/java/android/text/Html.java b/AndroidCompat/src/main/java/android/text/Html.java index 052afed02..443c8b274 100644 --- a/AndroidCompat/src/main/java/android/text/Html.java +++ b/AndroidCompat/src/main/java/android/text/Html.java @@ -4,7 +4,7 @@ import android.graphics.drawable.Drawable; import org.jetbrains.annotations.NotNull; import org.jsoup.Jsoup; -import org.jsoup.safety.Whitelist; +import org.jsoup.safety.Safelist; import org.xml.sax.XMLReader; /** @@ -18,7 +18,7 @@ public class Html { public static Spanned fromHtml(String source) { - return new FakeSpanned(Jsoup.clean(source, Whitelist.none())); + return new FakeSpanned(Jsoup.clean(source, Safelist.none())); } public static Spanned fromHtml(String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler) { diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt index d713c16ee..767355256 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt @@ -60,9 +60,13 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } private fun internalMove(row: Int) { - if (cursor < 0) cursor = 0 - else if (cursor > resultSetLength + 1) cursor = resultSetLength + 1 - else cursor = row + if (cursor < 0) { + cursor = 0 + } else if (cursor > resultSetLength + 1) { + cursor = resultSetLength + 1 + } else { + cursor = row + } } private fun obj(column: Int): Any? { @@ -293,10 +297,11 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } override fun unwrap(iface: Class?): T { - if (thisIsWrapperFor(iface)) + if (thisIsWrapperFor(iface)) { return this as T - else + } else { return parent.unwrap(iface) + } } override fun next(): Boolean { @@ -531,10 +536,15 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } private fun castToLong(obj: Any?): Long { - if (obj == null) return 0 - else if (obj is Long) return obj - else if (obj is Number) return obj.toLong() - else throw IllegalStateException("Object is not a long!") + if (obj == null) { + return 0 + } else if (obj is Long) { + return obj + } else if (obj is Number) { + return obj.toLong() + } else { + throw IllegalStateException("Object is not a long!") + } } override fun getLong(columnIndex: Int): Long { diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt index 9bdf85d2a..266ddc3cf 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt @@ -10,7 +10,7 @@ package xyz.nulldev.androidcompat.io.sharedprefs import android.content.SharedPreferences import com.russhwolf.settings.ExperimentalSettingsApi import com.russhwolf.settings.ExperimentalSettingsImplementation -import com.russhwolf.settings.JvmPreferencesSettings +import com.russhwolf.settings.PreferencesSettings import com.russhwolf.settings.serialization.decodeValue import com.russhwolf.settings.serialization.decodeValueOrNull import com.russhwolf.settings.serialization.encodeValue @@ -24,7 +24,7 @@ import java.util.prefs.Preferences @OptIn(ExperimentalSettingsImplementation::class, ExperimentalSerializationApi::class, ExperimentalSettingsApi::class) class JavaSharedPreferences(key: String) : SharedPreferences { private val javaPreferences = Preferences.userRoot().node("suwayomi/tachidesk/$key") - private val preferences = JvmPreferencesSettings(javaPreferences) + private val preferences = PreferencesSettings(javaPreferences) private val listeners = mutableMapOf() // TODO: 2021-05-29 Need to find a way to get this working with all pref types @@ -76,7 +76,7 @@ class JavaSharedPreferences(key: String) : SharedPreferences { return Editor(preferences) } - class Editor(private val preferences: JvmPreferencesSettings) : SharedPreferences.Editor { + class Editor(private val preferences: PreferencesSettings) : SharedPreferences.Editor { val itemsToAdd = mutableMapOf() override fun putString(key: String, value: String?): SharedPreferences.Editor { diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt index 7c0e6a371..f94f3222b 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt @@ -74,10 +74,11 @@ class PackageController { fun findPackage(packageName: String): InstalledPackage? { val file = File(androidFiles.packagesDir, packageName) - return if (file.exists()) + return if (file.exists()) { InstalledPackage(file) - else + } else { null + } } fun findJarFromApk(apkFile: File): File? { diff --git a/build.gradle.kts b/build.gradle.kts index 6b583e2b2..6693ac343 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,8 +5,9 @@ import org.jmailen.gradle.kotlinter.tasks.LintTask plugins { kotlin("jvm") version kotlinVersion kotlin("plugin.serialization") version kotlinVersion - id("org.jmailen.kotlinter") version "3.8.0" - id("com.github.gmazzo.buildconfig") version "3.0.3" apply false + id("org.jmailen.kotlinter") version "3.12.0" + id("com.github.gmazzo.buildconfig") version "3.1.0" apply false + id("de.undercouch.download") version "5.3.0" } allprojects { @@ -43,12 +44,6 @@ configure(projects) { dependsOn(formatKotlin) kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() - freeCompilerArgs = listOf( - "-Xopt-in=kotlin.RequiresOptIn", - "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xopt-in=kotlinx.coroutines.InternalCoroutinesApi", - "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi", - ) } } @@ -69,40 +64,42 @@ configure(projects) { testImplementation(kotlin("test-junit5")) // coroutines - val coroutinesVersion = "1.6.0" + val coroutinesVersion = "1.6.4" implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") - val kotlinSerializationVersion = "1.3.2" + val kotlinSerializationVersion = "1.4.1" implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion") implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinSerializationVersion") // Dependency Injection - implementation("org.kodein.di:kodein-di-conf-jvm:7.10.0") + implementation("org.kodein.di:kodein-di-conf-jvm:7.15.0") // Logging + // Stuck on old versions since + // 1. Logback 1.3.0+ requires Java 9 + // 2. Slf4j 2.0.0+ doesn't register older versions of Logback + // 3. Kotlin-logging 3.0.2+ requires Java 11, but this is probably a bug implementation("org.slf4j:slf4j-api:1.7.32") implementation("ch.qos.logback:logback-classic:1.2.6") implementation("io.github.microutils:kotlin-logging:2.1.21") // ReactiveX implementation("io.reactivex:rxjava:1.3.8") - implementation("io.reactivex:rxkotlin:1.0.0") - implementation("com.jakewharton.rxrelay:rxrelay:1.2.0") // dependency both in AndroidCompat and extensions, version locked by Tachiyomi app/extensions - implementation("org.jsoup:jsoup:1.14.3") + implementation("org.jsoup:jsoup:1.15.3") // dependency of :AndroidCompat:Config - implementation("com.typesafe:config:1.4.1") - implementation("io.github.config4k:config4k:0.4.2") + implementation("com.typesafe:config:1.4.2") + implementation("io.github.config4k:config4k:0.5.0") // to get application content root implementation("net.harawata:appdirs:1.2.1") // dex2jar - val dex2jarVersion = "v35" + val dex2jarVersion = "v56" implementation("com.github.ThexXTURBOXx.dex2jar:dex-translator:$dex2jarVersion") implementation("com.github.ThexXTURBOXx.dex2jar:dex-tools:$dex2jarVersion") diff --git a/buildSrc/src/main/kotlin/Constants.kt b/buildSrc/src/main/kotlin/Constants.kt index 007d076da..66ce71087 100644 --- a/buildSrc/src/main/kotlin/Constants.kt +++ b/buildSrc/src/main/kotlin/Constants.kt @@ -7,7 +7,7 @@ import java.io.BufferedReader * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -const val kotlinVersion = "1.6.10" +const val kotlinVersion = "1.7.20" const val MainClass = "suwayomi.tachidesk.MainKt" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b..ae04661ee 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 4c0d9e07a..e23d32b83 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -9,17 +9,18 @@ plugins { dependencies { // okhttp - val okhttpVersion = "4.9.3" // Major version is locked by Tachiyomi extensions + val okhttpVersion = "4.10.0" // Major version is locked by Tachiyomi extensions implementation("com.squareup.okhttp3:okhttp:$okhttpVersion") implementation("com.squareup.okhttp3:logging-interceptor:$okhttpVersion") implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion") - implementation("com.squareup.okio:okio:3.0.0") + implementation("com.squareup.okio:okio:3.2.0") // Javalin api - implementation("io.javalin:javalin:4.2.0") - implementation("io.javalin:javalin-openapi:4.2.0") + // Javalin 5.0.0+ requires Java 11 + implementation("io.javalin:javalin:4.6.6") + implementation("io.javalin:javalin-openapi:4.6.6") // jackson version locked by javalin, ref: `io.javalin.core.util.OptionalDependency` - val jacksonVersion = "2.12.4" + val jacksonVersion = "2.13.3" implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion") @@ -43,23 +44,23 @@ dependencies { implementation("com.github.inorichi.injekt:injekt-core:65b0440") implementation("com.squareup.okhttp3:okhttp:$okhttpVersion") implementation("io.reactivex:rxjava:1.3.8") - implementation("org.jsoup:jsoup:1.14.3") + implementation("org.jsoup:jsoup:1.15.3") // Sort implementation("com.github.gpanther:java-nat-sort:natural-comparator-1.1") // asm for ByteCodeEditor(fixing SimpleDateFormat) (must match Dex2Jar version) - implementation("org.ow2.asm:asm:9.2") + implementation("org.ow2.asm:asm:9.4") // Disk & File - implementation("net.lingala.zip4j:zip4j:2.9.1") - implementation("com.github.junrar:junrar:7.5.0") + implementation("net.lingala.zip4j:zip4j:2.11.2") + implementation("com.github.junrar:junrar:7.5.3") // CloudflareInterceptor - implementation("net.sourceforge.htmlunit:htmlunit:2.56.0") + implementation("net.sourceforge.htmlunit:htmlunit:2.65.1") // AES/CBC/PKCS7Padding Cypher provider for zh.copymanga - implementation("org.bouncycastle:bcprov-jdk18on:1.71") + implementation("org.bouncycastle:bcprov-jdk18on:1.72") // Source models and interfaces from Tachiyomi 1.x // using source class from tachiyomi commit 9493577de27c40ce8b2b6122cc447d025e34c477 to not depend on tachiyomi.sourceapi @@ -73,7 +74,7 @@ dependencies { // implementation(fileTree("lib/")) implementation(kotlin("script-runtime")) - testImplementation("io.mockk:mockk:1.12.2") + testImplementation("io.mockk:mockk:1.13.2") } application { diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt index 1c363994b..c46b8d1c8 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt @@ -29,7 +29,6 @@ import uy.kohesive.injekt.api.get class AppModule(val app: Application) : InjektModule { override fun InjektRegistrar.registerInjectables() { - addSingleton(app) // addSingletonFactory { PreferencesHelper(app) } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt index a776f2b5f..585870001 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt @@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit fun OkHttpClient.Builder.rateLimit( permits: Int, period: Long = 1, - unit: TimeUnit = TimeUnit.SECONDS, + unit: TimeUnit = TimeUnit.SECONDS ) = addInterceptor(RateLimitInterceptor(permits, period, unit)) private class RateLimitInterceptor( private val permits: Int, period: Long, - unit: TimeUnit, + unit: TimeUnit ) : Interceptor { private val requestQueue = ArrayList(permits) diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt index ec7a8fdb1..2851a9b8b 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt @@ -26,14 +26,14 @@ fun OkHttpClient.Builder.rateLimitHost( httpUrl: HttpUrl, permits: Int, period: Long = 1, - unit: TimeUnit = TimeUnit.SECONDS, + unit: TimeUnit = TimeUnit.SECONDS ) = addInterceptor(SpecificHostRateLimitInterceptor(httpUrl, permits, period, unit)) class SpecificHostRateLimitInterceptor( httpUrl: HttpUrl, private val permits: Int, period: Long, - unit: TimeUnit, + unit: TimeUnit ) : Interceptor { private val requestQueue = ArrayList(permits) diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt index 40d747176..0aaaf01f8 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt @@ -327,8 +327,9 @@ class LocalSource : CatalogueSource { fun getFormat(chapter: SChapter): Format { val chapFile = File(applicationDirs.localMangaRoot, chapter.url) - if (chapFile.exists()) + if (chapFile.exists()) { return getFormat(chapFile) + } throw Exception("Chapter not found") } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/util/storage/EpubFile.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/util/storage/EpubFile.kt index 9a8b24be8..5ceb93677 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/util/storage/EpubFile.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/util/storage/EpubFile.kt @@ -139,7 +139,7 @@ class EpubFile(file: File) : Closeable { */ private fun getPagesFromDocument(document: Document): List { val pages = document.select("manifest > item") - .filter { "application/xhtml+xml" == it.attr("media-type") } + .filter { element -> "application/xhtml+xml" == element.attr("media-type") } .associateBy { it.attr("id") } val spine = document.select("spine > itemref").map { it.attr("idref") } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt index 84b8f0a10..8bc79b649 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt @@ -16,7 +16,7 @@ data class AboutDataClass( val buildType: String, val buildTime: Long, val github: String, - val discord: String, + val discord: String ) object About { @@ -28,7 +28,7 @@ object About { BuildConfig.BUILD_TYPE, BuildConfig.BUILD_TIME, BuildConfig.GITHUB, - BuildConfig.DISCORD, + BuildConfig.DISCORD ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt index 8f8384e8a..e3b14ac1e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt @@ -46,13 +46,13 @@ object AppUpdate { UpdateDataClass( "Stable", stableJson["tag_name"]!!.jsonPrimitive.content, - stableJson["html_url"]!!.jsonPrimitive.content, + stableJson["html_url"]!!.jsonPrimitive.content ), UpdateDataClass( "Preview", previewJson["tag_name"]!!.jsonPrimitive.content, - previewJson["html_url"]!!.jsonPrimitive.content, - ), + previewJson["html_url"]!!.jsonPrimitive.content + ) ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt index 499e2e15c..64008b68a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt @@ -85,7 +85,7 @@ object BackupController { includeCategories = true, includeChapters = true, includeTracking = true, - includeHistory = true, + includeHistory = true ) ) } @@ -117,7 +117,7 @@ object BackupController { includeCategories = true, includeChapters = true, includeTracking = true, - includeHistory = true, + includeHistory = true ) ) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt index 46bb71108..acd9e6346 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt @@ -41,7 +41,9 @@ object Category { normalizeCategories() newCategoryId - } else -1 + } else { + -1 + } } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt index 67cd7d617..ebc270028 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt @@ -86,13 +86,14 @@ object CategoryManga { dataClass } - if (categoryId == DEFAULT_CATEGORY_ID) + if (categoryId == DEFAULT_CATEGORY_ID) { return transaction { MangaTable .slice(selectedColumns) .select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) } .map(transform) } + } return transaction { CategoryMangaTable.innerJoin(MangaTable) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index aa187dea0..0de8faffc 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -106,7 +106,9 @@ object Chapter { val dbChapterCount = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count() } if (dbChapterCount > chapterCount) { // we got some clean up due val dbChapterList = transaction { - ChapterTable.select { ChapterTable.manga eq mangaId }.orderBy(ChapterTable.url to ASC).toList() + ChapterTable.select { ChapterTable.manga eq mangaId } + .orderBy(ChapterTable.url to ASC) + .toList() } val chapterUrls = chapterList.map { it.url }.toSet() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt index 11ee265e6..6f04fc49f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt @@ -45,10 +45,11 @@ import java.io.InputStream object Manga { private fun truncate(text: String?, maxLength: Int): String? { - return if (text?.length ?: 0 > maxLength) + return if (text?.length ?: 0 > maxLength) { text?.take(maxLength - 3) + "..." - else + } else { text + } } suspend fun getManga(mangaId: Int, onlineFetch: Boolean = false): MangaDataClass { @@ -68,12 +69,12 @@ object Manga { transaction { MangaTable.update({ MangaTable.id eq mangaId }) { - if (sManga.title != mangaEntry[MangaTable.title]) { val canUpdateTitle = updateMangaDownloadDir(mangaId, sManga.title) - if (canUpdateTitle) + if (canUpdateTitle) { it[MangaTable.title] = sManga.title + } } it[MangaTable.initialized] = true @@ -82,8 +83,9 @@ object Manga { it[MangaTable.description] = truncate(sManga.description, 4096) it[MangaTable.genre] = sManga.genre it[MangaTable.status] = sManga.status - if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty()) + if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty()) { it[MangaTable.thumbnail_url] = sManga.thumbnail_url + } it[MangaTable.realUrl] = runCatching { (source as? HttpSource)?.mangaDetailsRequest(sManga)?.url?.toString() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt index ed64f31bf..ad8407e2b 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt @@ -78,7 +78,7 @@ object Search { data class FilterObject( val type: String, - val filter: Filter<*>, + val filter: Filter<*> ) fun setFilter(sourceId: Long, changes: List) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt index 6df0f7c88..d151abe8c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt @@ -48,7 +48,7 @@ object Source { catalogueSource.supportsLatest, catalogueSource is ConfigurableSource, it[SourceTable.isNsfw], - catalogueSource.toString(), + catalogueSource.toString() ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt index 05c69546b..d06b61674 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt @@ -12,5 +12,5 @@ data class BackupFlags( val includeCategories: Boolean, val includeChapters: Boolean, val includeTracking: Boolean, - val includeHistory: Boolean, + val includeHistory: Boolean ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt index 7b593e6a1..ce9a37ce0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt @@ -69,7 +69,7 @@ object ProtoBackupExport : ProtoBackupBase() { MangaStatus.valueOf(mangaRow[MangaTable.status]).value, mangaRow[MangaTable.thumbnail_url], TimeUnit.SECONDS.toMillis(mangaRow[MangaTable.inLibraryAt]), - 0, // not supported in Tachidesk + 0 // not supported in Tachidesk ) val mangaId = mangaRow[MangaTable.id].value @@ -94,7 +94,7 @@ object ProtoBackupExport : ProtoBackupBase() { TimeUnit.SECONDS.toMillis(it.fetchedAt), it.uploadDate, it.chapterNumber, - chapters.size - it.index, + chapters.size - it.index ) } } @@ -122,7 +122,7 @@ object ProtoBackupExport : ProtoBackupBase() { BackupCategory( it.name, it.order, - 0, // not supported in Tachidesk + 0 // not supported in Tachidesk ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt index c32fb2035..177b9a0e1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt @@ -9,7 +9,7 @@ data class Backup( @ProtoNumber(2) var backupCategories: List = emptyList(), // Bump by 100 to specify this is a 0.x value @ProtoNumber(100) var brokenBackupSources: List = emptyList(), - @ProtoNumber(101) var backupSources: List = emptyList(), + @ProtoNumber(101) var backupSources: List = emptyList() ) { fun getSourceMap(): Map { return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt index 33479aaae..5b7c95c65 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt @@ -11,7 +11,7 @@ class BackupCategory( @ProtoNumber(2) var order: Int = 0, // @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x // Bump by 100 to specify this is a 0.x value - @ProtoNumber(100) var flags: Int = 0, + @ProtoNumber(100) var flags: Int = 0 ) { fun getCategoryImpl(): CategoryImpl { return CategoryImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt index 38691c0e0..b493f1d56 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt @@ -20,7 +20,7 @@ data class BackupChapter( @ProtoNumber(8) var dateUpload: Long = 0, // chapterNumber is called number is 1.x @ProtoNumber(9) var chapterNumber: Float = 0F, - @ProtoNumber(10) var sourceOrder: Int = 0, + @ProtoNumber(10) var sourceOrder: Int = 0 ) { fun toChapterImpl(): ChapterImpl { return ChapterImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt index 16b4e9e36..aff20da4a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt @@ -35,7 +35,7 @@ data class BackupManga( @ProtoNumber(101) var chapterFlags: Int = 0, @ProtoNumber(102) var brokenHistory: List = emptyList(), @ProtoNumber(103) var viewer_flags: Int? = null, - @ProtoNumber(104) var history: List = emptyList(), + @ProtoNumber(104) var history: List = emptyList() ) { fun getMangaImpl(): MangaImpl { return MangaImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt index 662c70ff4..4135085e4 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt @@ -24,7 +24,7 @@ data class BackupTracking( // startedReadingDate is called startReadTime in 1.x @ProtoNumber(10) var startedReadingDate: Long = 0, // finishedReadingDate is called endReadTime in 1.x - @ProtoNumber(11) var finishedReadingDate: Long = 0, + @ProtoNumber(11) var finishedReadingDate: Long = 0 ) { fun getTrackingImpl(): TrackImpl { return TrackImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt index ddaa6256c..c1f89a1b0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt @@ -37,7 +37,6 @@ private class ChapterForDownload( private val mangaId: Int ) { suspend fun asDownloadReady(): ChapterDataClass { - if (isNotCompletelyDownloaded()) { markAsNotDownloaded() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt index 4a726005c..987809181 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt @@ -49,7 +49,8 @@ object DownloadManager { |Supported commands are: | - STATUS | sends the current download status - |""".trimMargin() + | + """.trimMargin() ) } } @@ -65,7 +66,11 @@ object DownloadManager { return DownloadStatus( if (downloader == null || downloadQueue.none { it.state == Downloading } - ) "Stopped" else "Started", + ) { + "Stopped" + } else { + "Started" + }, downloadQueue ) } @@ -96,8 +101,10 @@ object DownloadManager { } fun start() { - if (downloader != null && !downloader?.isAlive!!) // doesn't exist or is dead + if (downloader != null && !downloader?.isAlive!!) { + // doesn't exist or is dead downloader = null + } if (downloader == null) { downloader = Downloader(downloadQueue) { notifyAllClients() } @@ -127,5 +134,5 @@ object DownloadManager { enum class DownloaderState(val state: Int) { Stopped(0), Running(1), - Paused(2), + Paused(2) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt index 087463d39..f101150b6 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt @@ -18,5 +18,5 @@ class DownloadChapter( var manga: MangaDataClass, var state: DownloadState = Queued, var progress: Float = 0f, - var tries: Int = 0, + var tries: Int = 0 ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt index 61ef7d11b..5be5d609e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt @@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) { Queued(0), Downloading(1), Finished(2), - Error(3), + Error(3) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt index 8768813c0..c2f748afb 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model data class DownloadStatus( val status: String, - val queue: List, + val queue: List ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt index ae49f6946..4a8f248f8 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt @@ -225,12 +225,13 @@ object Extension { SourceTable.deleteWhere { SourceTable.extension eq extensionId } - if (extensionRecord[ExtensionTable.isObsolete]) + if (extensionRecord[ExtensionTable.isObsolete]) { ExtensionTable.deleteWhere { ExtensionTable.pkgName eq pkgName } - else + } else { ExtensionTable.update({ ExtensionTable.pkgName eq pkgName }) { it[isInstalled] = false } + } sources } @@ -265,8 +266,11 @@ object Extension { } suspend fun getExtensionIcon(apkName: String, useCache: Boolean): Pair { - val iconUrl = if (apkName == "localSource") "" - else transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] + val iconUrl = if (apkName == "localSource") { + "" + } else { + transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] + } val saveDir = "${applicationDirs.extensionsRoot}/icon" diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt index cbdeac1d9..82cca9f9d 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt @@ -59,7 +59,7 @@ object ExtensionsList { it[ExtensionTable.isNsfw], it[ExtensionTable.isInstalled], it[ExtensionTable.hasUpdate], - it[ExtensionTable.isObsolete], + it[ExtensionTable.isObsolete] ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt index 537d25c42..45c8c7208 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt @@ -31,7 +31,7 @@ object ExtensionGithubApi { val nsfw: Int, val hasReadme: Int = 0, val hasChangelog: Int = 0, - val sources: List?, + val sources: List? ) @Serializable diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt index 69d901c54..cafa504c0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt @@ -32,7 +32,8 @@ object UpdaterSocket : Websocket() { |Supported commands are: | - STATUS | sends the current update status - |""".trimMargin() + | + """.trimMargin() ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt index 59d0a8617..0deeaa2cf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt @@ -67,7 +67,9 @@ object BytecodeEditor { } path to bytes - } else null + } else { + null + } } catch (e: Exception) { logger.error(e) { "Error loading class from Path: $path" } null @@ -172,7 +174,11 @@ object BytecodeEditor { ): MethodVisitor { logger.trace { "Processing method $name: ${desc.replaceIndirectly()}: $signature" } val mv: MethodVisitor? = super.visitMethod( - access, name, desc.replaceIndirectly(), signature, exceptions + access, + name, + desc.replaceIndirectly(), + signature, + exceptions ) return object : MethodVisitor(Opcodes.ASM5, mv) { override fun visitLdcInsn(cst: Any?) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt index a49fad044..f19f0f63f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt @@ -60,7 +60,9 @@ fun updateMangaDownloadDir(mangaId: Int, newTitle: String): Boolean { val oldDirFile = File(oldDir) val newDirFile = File(newDir) - return if (oldDirFile.exists()) + return if (oldDirFile.exists()) { oldDirFile.renameTo(newDirFile) - else true + } else { + true + } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt index 6f8a80b1d..5b07e817e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt @@ -8,6 +8,7 @@ package suwayomi.tachidesk.manga.impl.util.lang * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import kotlinx.coroutines.CancellableContinuation +import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.suspendCancellableCoroutine import rx.Observable import rx.Subscriber @@ -22,6 +23,7 @@ import kotlin.coroutines.resumeWithException suspend fun Observable.awaitSingle(): T = single().awaitOne() +@OptIn(InternalCoroutinesApi::class) private suspend fun Observable.awaitOne(): T = suspendCancellableCoroutine { cont -> cont.unsubscribeOnCancellation( subscribe( @@ -35,11 +37,13 @@ private suspend fun Observable.awaitOne(): T = suspendCancellableCoroutin } override fun onCompleted() { - if (cont.isActive) cont.resumeWithException( - IllegalStateException( - "Should have invoked onNext" + if (cont.isActive) { + cont.resumeWithException( + IllegalStateException( + "Should have invoked onNext" + ) ) - ) + } } override fun onError(e: Throwable) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt index f782adc3b..2c8d9cc14 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt @@ -21,8 +21,9 @@ object ImageResponse { fun findFileNameStartingWith(directoryPath: String, fileName: String): String? { val target = "$fileName." File(directoryPath).listFiles().orEmpty().forEach { file -> - if (file.name.startsWith(target)) + if (file.name.startsWith(target)) { return "$directoryPath/${file.name}" + } } return null } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt index a60730223..e996358d7 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt @@ -44,5 +44,5 @@ data class ChapterDataClass( val chapterCount: Int? = null, /** used to store client specific values */ - val meta: Map = emptyMap(), + val meta: Map = emptyMap() ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt index af8506533..f3db7b72e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt @@ -20,5 +20,5 @@ data class ExtensionDataClass( val installed: Boolean, val hasUpdate: Boolean, - val obsolete: Boolean, + val obsolete: Boolean ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt index c76298843..54d763e8e 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass data class MangaChapterDataClass( val manga: MangaDataClass, - val chapter: ChapterDataClass, + val chapter: ChapterDataClass ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt index 48cfbc65f..0687e14bf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass data class PageDataClass( val index: Int, - var imageUrl: String, + var imageUrl: String ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt index 4a38a9167..7deefd65c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt @@ -11,7 +11,7 @@ import kotlin.math.min open class PaginatedList( val page: List, - val hasNextPage: Boolean, + val hasNextPage: Boolean ) const val PaginationFactor = 50 diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt index 7aefb7e2d..ca9e6a2f1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt @@ -25,5 +25,5 @@ data class SourceDataClass( val isNsfw: Boolean, /** A nicer version of [name] */ - val displayName: String, + val displayName: String ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt index c00f7cad2..0bcc0fd22 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt @@ -21,5 +21,5 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass( categoryEntry[this.id].value, categoryEntry[order], categoryEntry[name], - categoryEntry[isDefault], + categoryEntry[isDefault] ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt index 47d704d68..19bc49f7a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt @@ -53,5 +53,5 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) = chapterEntry[isDownloaded], chapterEntry[pageCount], transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() }, - getChapterMetaMap(chapterEntry[id]), + getChapterMetaMap(chapterEntry[id]) ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt index cba2c39b6..4a3798d88 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt @@ -59,7 +59,7 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) = mangaEntry[inLibrary], mangaEntry[inLibraryAt], meta = getMangaMetaMap(mangaEntry[id].value), - realUrl = mangaEntry[realUrl], + realUrl = mangaEntry[realUrl] ) enum class MangaStatus(val value: Int) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt index d10a7afc5..e5c04e03a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt @@ -85,7 +85,7 @@ fun applicationSetup() { applicationDirs.extensionsRoot + "/icon", applicationDirs.thumbnailsRoot, applicationDirs.mangaDownloadsRoot, - applicationDirs.localMangaRoot, + applicationDirs.localMangaRoot ).forEach { File(it).mkdirs() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt index 6837268e1..ce0384720 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt @@ -13,8 +13,8 @@ import org.jetbrains.exposed.dao.id.IdTable import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.Table -@Suppress("ClassName", "unused") /** initial migration, create all tables */ +@Suppress("ClassName", "unused") class M0001_Initial : AddTableMigration() { private class ExtensionTable : IntIdTable() { init { @@ -128,7 +128,7 @@ class M0001_Initial : AddTableMigration() { chapterTable, pageTable, categoryTable, - categoryMangaTable, + categoryMangaTable ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt index fbf57385a..9be9429be 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt @@ -12,5 +12,5 @@ import de.neonew.exposed.migrations.helpers.DropColumnMigration @Suppress("ClassName", "unused") class M0011_SourceDropPartOfFactorySource : DropColumnMigration( "Source", - "part_of_factory_source", + "part_of_factory_source" ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt index d72ce6663..bb20559e0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt @@ -242,7 +242,7 @@ inline fun handler( it, getParam(it, param1), getParam(it, param2), - getParam(it, param3), + getParam(it, param3) ) } ) @@ -265,7 +265,7 @@ inline fun handler( getParam(it, param1), getParam(it, param2), getParam(it, param3), - getParam(it, param4), + getParam(it, param4) ) } ) @@ -290,7 +290,7 @@ inline fun handler( getParam(it, param2), getParam(it, param3), getParam(it, param4), - getParam(it, param5), + getParam(it, param5) ) } ) @@ -317,7 +317,7 @@ inline fun >)[0]), FilterObject("CheckBox", (source.mFilterList[6].state as List>)[1]), - FilterObject("CheckBox", (source.mFilterList[6].state as List>)[2]), + FilterObject("CheckBox", (source.mFilterList[6].state as List>)[2]) ) ) ) diff --git a/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt b/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt index a429c3bb6..c6b6dd6f6 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt @@ -31,7 +31,7 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor - 1), false), - paginated, + paginated ) } @@ -43,14 +43,14 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage, + firstPage ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false), - secondPage, + secondPage ) } @@ -62,14 +62,14 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage, + firstPage ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false), - secondPage, + secondPage ) } @@ -81,21 +81,21 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage, + firstPage ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true), - secondPage, + secondPage ) val thirdPage = paginatedFrom(2, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false), - thirdPage, + thirdPage ) } diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt index 486832090..69171a190 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt @@ -76,7 +76,7 @@ open class ApplicationTest { applicationDirs.extensionsRoot + "/icon", applicationDirs.thumbnailsRoot, applicationDirs.mangaDownloadsRoot, - applicationDirs.localMangaRoot, + applicationDirs.localMangaRoot ).forEach { File(it).mkdirs() } diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt index dffbe8b1f..d6b827374 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt @@ -23,7 +23,9 @@ fun setLoggingEnabled(enabled: Boolean = true) { val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger) logger.level = if (enabled) { Level.DEBUG - } else Level.ERROR + } else { + Level.ERROR + } } const val BASE_PATH = "build/tmp/TestDesk" From 0abf82a05d0f832cb2f5f0ddf897b4fe8fed4cf1 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Fri, 21 Oct 2022 19:57:58 -0400 Subject: [PATCH 2/2] Revert lint --- .../androidcompat/db/ScrollableResultSet.kt | 28 ++++++------------- .../androidcompat/pm/PackageController.kt | 5 ++-- .../kotlin/eu/kanade/tachiyomi/AppModule.kt | 1 + .../interceptor/RateLimitInterceptor.kt | 4 +-- .../SpecificHostRateLimitInterceptor.kt | 4 +-- .../tachiyomi/source/local/LocalSource.kt | 3 +- .../suwayomi/tachidesk/global/impl/About.kt | 4 +-- .../tachidesk/global/impl/AppUpdate.kt | 6 ++-- .../manga/controller/BackupController.kt | 4 +-- .../suwayomi/tachidesk/manga/impl/Category.kt | 4 +-- .../tachidesk/manga/impl/CategoryManga.kt | 3 +- .../suwayomi/tachidesk/manga/impl/Chapter.kt | 4 +-- .../suwayomi/tachidesk/manga/impl/Manga.kt | 12 ++++---- .../suwayomi/tachidesk/manga/impl/Search.kt | 2 +- .../suwayomi/tachidesk/manga/impl/Source.kt | 2 +- .../manga/impl/backup/BackupFlags.kt | 2 +- .../impl/backup/proto/ProtoBackupExport.kt | 6 ++-- .../manga/impl/backup/proto/models/Backup.kt | 2 +- .../backup/proto/models/BackupCategory.kt | 2 +- .../impl/backup/proto/models/BackupChapter.kt | 2 +- .../impl/backup/proto/models/BackupManga.kt | 2 +- .../backup/proto/models/BackupTracking.kt | 2 +- .../manga/impl/chapter/ChapterForDownload.kt | 1 + .../manga/impl/download/DownloadManager.kt | 15 +++------- .../impl/download/model/DownloadChapter.kt | 2 +- .../impl/download/model/DownloadState.kt | 2 +- .../impl/download/model/DownloadStatus.kt | 2 +- .../manga/impl/extension/Extension.kt | 12 +++----- .../manga/impl/extension/ExtensionsList.kt | 2 +- .../extension/github/ExtensionGithubApi.kt | 2 +- .../manga/impl/update/UpdaterSocket.kt | 3 +- .../manga/impl/util/BytecodeEditor.kt | 10 ++----- .../tachidesk/manga/impl/util/DirName.kt | 6 ++-- .../manga/impl/util/lang/RxCoroutineBridge.kt | 10 +++---- .../manga/impl/util/storage/ImageResponse.kt | 3 +- .../manga/model/dataclass/ChapterDataClass.kt | 2 +- .../model/dataclass/ExtensionDataClass.kt | 2 +- .../model/dataclass/MangaChapterDataClass.kt | 2 +- .../manga/model/dataclass/PageDataClass.kt | 2 +- .../manga/model/dataclass/PaginatedList.kt | 2 +- .../manga/model/dataclass/SourceDataClass.kt | 2 +- .../manga/model/table/CategoryTable.kt | 2 +- .../manga/model/table/ChapterTable.kt | 2 +- .../tachidesk/manga/model/table/MangaTable.kt | 2 +- .../suwayomi/tachidesk/server/ServerSetup.kt | 2 +- .../database/migration/M0001_Initial.kt | 4 +-- .../M0011_SourceDropPartOfFactorySource.kt | 2 +- .../tachidesk/server/util/DocumentationDsl.kt | 16 +++++------ .../server/util/WebInterfaceManager.kt | 3 +- .../tachidesk/manga/impl/CategoryMangaTest.kt | 15 ++++------ .../tachidesk/manga/impl/MangaTest.kt | 9 ++---- .../tachidesk/manga/impl/SearchTest.kt | 7 ++--- .../manga/model/PaginatedListTest.kt | 16 +++++------ .../tachidesk/test/ApplicationTest.kt | 2 +- .../suwayomi/tachidesk/test/TestUtils.kt | 4 +-- 55 files changed, 110 insertions(+), 162 deletions(-) diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt index 767355256..d713c16ee 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/db/ScrollableResultSet.kt @@ -60,13 +60,9 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } private fun internalMove(row: Int) { - if (cursor < 0) { - cursor = 0 - } else if (cursor > resultSetLength + 1) { - cursor = resultSetLength + 1 - } else { - cursor = row - } + if (cursor < 0) cursor = 0 + else if (cursor > resultSetLength + 1) cursor = resultSetLength + 1 + else cursor = row } private fun obj(column: Int): Any? { @@ -297,11 +293,10 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } override fun unwrap(iface: Class?): T { - if (thisIsWrapperFor(iface)) { + if (thisIsWrapperFor(iface)) return this as T - } else { + else return parent.unwrap(iface) - } } override fun next(): Boolean { @@ -536,15 +531,10 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent { } private fun castToLong(obj: Any?): Long { - if (obj == null) { - return 0 - } else if (obj is Long) { - return obj - } else if (obj is Number) { - return obj.toLong() - } else { - throw IllegalStateException("Object is not a long!") - } + if (obj == null) return 0 + else if (obj is Long) return obj + else if (obj is Number) return obj.toLong() + else throw IllegalStateException("Object is not a long!") } override fun getLong(columnIndex: Int): Long { diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt index f94f3222b..7c0e6a371 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/pm/PackageController.kt @@ -74,11 +74,10 @@ class PackageController { fun findPackage(packageName: String): InstalledPackage? { val file = File(androidFiles.packagesDir, packageName) - return if (file.exists()) { + return if (file.exists()) InstalledPackage(file) - } else { + else null - } } fun findJarFromApk(apkFile: File): File? { diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt index c46b8d1c8..1c363994b 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/AppModule.kt @@ -29,6 +29,7 @@ import uy.kohesive.injekt.api.get class AppModule(val app: Application) : InjektModule { override fun InjektRegistrar.registerInjectables() { + addSingleton(app) // addSingletonFactory { PreferencesHelper(app) } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt index 585870001..a776f2b5f 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/RateLimitInterceptor.kt @@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit fun OkHttpClient.Builder.rateLimit( permits: Int, period: Long = 1, - unit: TimeUnit = TimeUnit.SECONDS + unit: TimeUnit = TimeUnit.SECONDS, ) = addInterceptor(RateLimitInterceptor(permits, period, unit)) private class RateLimitInterceptor( private val permits: Int, period: Long, - unit: TimeUnit + unit: TimeUnit, ) : Interceptor { private val requestQueue = ArrayList(permits) diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt index 2851a9b8b..ec7a8fdb1 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/SpecificHostRateLimitInterceptor.kt @@ -26,14 +26,14 @@ fun OkHttpClient.Builder.rateLimitHost( httpUrl: HttpUrl, permits: Int, period: Long = 1, - unit: TimeUnit = TimeUnit.SECONDS + unit: TimeUnit = TimeUnit.SECONDS, ) = addInterceptor(SpecificHostRateLimitInterceptor(httpUrl, permits, period, unit)) class SpecificHostRateLimitInterceptor( httpUrl: HttpUrl, private val permits: Int, period: Long, - unit: TimeUnit + unit: TimeUnit, ) : Interceptor { private val requestQueue = ArrayList(permits) diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt index 0aaaf01f8..40d747176 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt @@ -327,9 +327,8 @@ class LocalSource : CatalogueSource { fun getFormat(chapter: SChapter): Format { val chapFile = File(applicationDirs.localMangaRoot, chapter.url) - if (chapFile.exists()) { + if (chapFile.exists()) return getFormat(chapFile) - } throw Exception("Chapter not found") } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt index 8bc79b649..84b8f0a10 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/About.kt @@ -16,7 +16,7 @@ data class AboutDataClass( val buildType: String, val buildTime: Long, val github: String, - val discord: String + val discord: String, ) object About { @@ -28,7 +28,7 @@ object About { BuildConfig.BUILD_TYPE, BuildConfig.BUILD_TIME, BuildConfig.GITHUB, - BuildConfig.DISCORD + BuildConfig.DISCORD, ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt index e3b14ac1e..8f8384e8a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/AppUpdate.kt @@ -46,13 +46,13 @@ object AppUpdate { UpdateDataClass( "Stable", stableJson["tag_name"]!!.jsonPrimitive.content, - stableJson["html_url"]!!.jsonPrimitive.content + stableJson["html_url"]!!.jsonPrimitive.content, ), UpdateDataClass( "Preview", previewJson["tag_name"]!!.jsonPrimitive.content, - previewJson["html_url"]!!.jsonPrimitive.content - ) + previewJson["html_url"]!!.jsonPrimitive.content, + ), ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt index 64008b68a..499e2e15c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/BackupController.kt @@ -85,7 +85,7 @@ object BackupController { includeCategories = true, includeChapters = true, includeTracking = true, - includeHistory = true + includeHistory = true, ) ) } @@ -117,7 +117,7 @@ object BackupController { includeCategories = true, includeChapters = true, includeTracking = true, - includeHistory = true + includeHistory = true, ) ) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt index acd9e6346..46bb71108 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt @@ -41,9 +41,7 @@ object Category { normalizeCategories() newCategoryId - } else { - -1 - } + } else -1 } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt index ebc270028..67cd7d617 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt @@ -86,14 +86,13 @@ object CategoryManga { dataClass } - if (categoryId == DEFAULT_CATEGORY_ID) { + if (categoryId == DEFAULT_CATEGORY_ID) return transaction { MangaTable .slice(selectedColumns) .select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) } .map(transform) } - } return transaction { CategoryMangaTable.innerJoin(MangaTable) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index 0de8faffc..aa187dea0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -106,9 +106,7 @@ object Chapter { val dbChapterCount = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count() } if (dbChapterCount > chapterCount) { // we got some clean up due val dbChapterList = transaction { - ChapterTable.select { ChapterTable.manga eq mangaId } - .orderBy(ChapterTable.url to ASC) - .toList() + ChapterTable.select { ChapterTable.manga eq mangaId }.orderBy(ChapterTable.url to ASC).toList() } val chapterUrls = chapterList.map { it.url }.toSet() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt index 6f04fc49f..11ee265e6 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt @@ -45,11 +45,10 @@ import java.io.InputStream object Manga { private fun truncate(text: String?, maxLength: Int): String? { - return if (text?.length ?: 0 > maxLength) { + return if (text?.length ?: 0 > maxLength) text?.take(maxLength - 3) + "..." - } else { + else text - } } suspend fun getManga(mangaId: Int, onlineFetch: Boolean = false): MangaDataClass { @@ -69,12 +68,12 @@ object Manga { transaction { MangaTable.update({ MangaTable.id eq mangaId }) { + if (sManga.title != mangaEntry[MangaTable.title]) { val canUpdateTitle = updateMangaDownloadDir(mangaId, sManga.title) - if (canUpdateTitle) { + if (canUpdateTitle) it[MangaTable.title] = sManga.title - } } it[MangaTable.initialized] = true @@ -83,9 +82,8 @@ object Manga { it[MangaTable.description] = truncate(sManga.description, 4096) it[MangaTable.genre] = sManga.genre it[MangaTable.status] = sManga.status - if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty()) { + if (sManga.thumbnail_url != null && sManga.thumbnail_url.orEmpty().isNotEmpty()) it[MangaTable.thumbnail_url] = sManga.thumbnail_url - } it[MangaTable.realUrl] = runCatching { (source as? HttpSource)?.mangaDetailsRequest(sManga)?.url?.toString() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt index ad8407e2b..ed64f31bf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Search.kt @@ -78,7 +78,7 @@ object Search { data class FilterObject( val type: String, - val filter: Filter<*> + val filter: Filter<*>, ) fun setFilter(sourceId: Long, changes: List) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt index d151abe8c..6df0f7c88 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt @@ -48,7 +48,7 @@ object Source { catalogueSource.supportsLatest, catalogueSource is ConfigurableSource, it[SourceTable.isNsfw], - catalogueSource.toString() + catalogueSource.toString(), ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt index d06b61674..05c69546b 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/BackupFlags.kt @@ -12,5 +12,5 @@ data class BackupFlags( val includeCategories: Boolean, val includeChapters: Boolean, val includeTracking: Boolean, - val includeHistory: Boolean + val includeHistory: Boolean, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt index ce9a37ce0..7b593e6a1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt @@ -69,7 +69,7 @@ object ProtoBackupExport : ProtoBackupBase() { MangaStatus.valueOf(mangaRow[MangaTable.status]).value, mangaRow[MangaTable.thumbnail_url], TimeUnit.SECONDS.toMillis(mangaRow[MangaTable.inLibraryAt]), - 0 // not supported in Tachidesk + 0, // not supported in Tachidesk ) val mangaId = mangaRow[MangaTable.id].value @@ -94,7 +94,7 @@ object ProtoBackupExport : ProtoBackupBase() { TimeUnit.SECONDS.toMillis(it.fetchedAt), it.uploadDate, it.chapterNumber, - chapters.size - it.index + chapters.size - it.index, ) } } @@ -122,7 +122,7 @@ object ProtoBackupExport : ProtoBackupBase() { BackupCategory( it.name, it.order, - 0 // not supported in Tachidesk + 0, // not supported in Tachidesk ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt index 177b9a0e1..c32fb2035 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/Backup.kt @@ -9,7 +9,7 @@ data class Backup( @ProtoNumber(2) var backupCategories: List = emptyList(), // Bump by 100 to specify this is a 0.x value @ProtoNumber(100) var brokenBackupSources: List = emptyList(), - @ProtoNumber(101) var backupSources: List = emptyList() + @ProtoNumber(101) var backupSources: List = emptyList(), ) { fun getSourceMap(): Map { return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt index 5b7c95c65..33479aaae 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupCategory.kt @@ -11,7 +11,7 @@ class BackupCategory( @ProtoNumber(2) var order: Int = 0, // @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x // Bump by 100 to specify this is a 0.x value - @ProtoNumber(100) var flags: Int = 0 + @ProtoNumber(100) var flags: Int = 0, ) { fun getCategoryImpl(): CategoryImpl { return CategoryImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt index b493f1d56..38691c0e0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupChapter.kt @@ -20,7 +20,7 @@ data class BackupChapter( @ProtoNumber(8) var dateUpload: Long = 0, // chapterNumber is called number is 1.x @ProtoNumber(9) var chapterNumber: Float = 0F, - @ProtoNumber(10) var sourceOrder: Int = 0 + @ProtoNumber(10) var sourceOrder: Int = 0, ) { fun toChapterImpl(): ChapterImpl { return ChapterImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt index aff20da4a..16b4e9e36 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupManga.kt @@ -35,7 +35,7 @@ data class BackupManga( @ProtoNumber(101) var chapterFlags: Int = 0, @ProtoNumber(102) var brokenHistory: List = emptyList(), @ProtoNumber(103) var viewer_flags: Int? = null, - @ProtoNumber(104) var history: List = emptyList() + @ProtoNumber(104) var history: List = emptyList(), ) { fun getMangaImpl(): MangaImpl { return MangaImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt index 4135085e4..662c70ff4 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/models/BackupTracking.kt @@ -24,7 +24,7 @@ data class BackupTracking( // startedReadingDate is called startReadTime in 1.x @ProtoNumber(10) var startedReadingDate: Long = 0, // finishedReadingDate is called endReadTime in 1.x - @ProtoNumber(11) var finishedReadingDate: Long = 0 + @ProtoNumber(11) var finishedReadingDate: Long = 0, ) { fun getTrackingImpl(): TrackImpl { return TrackImpl().apply { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt index c1f89a1b0..ddaa6256c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt @@ -37,6 +37,7 @@ private class ChapterForDownload( private val mangaId: Int ) { suspend fun asDownloadReady(): ChapterDataClass { + if (isNotCompletelyDownloaded()) { markAsNotDownloaded() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt index 987809181..4a726005c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt @@ -49,8 +49,7 @@ object DownloadManager { |Supported commands are: | - STATUS | sends the current download status - | - """.trimMargin() + |""".trimMargin() ) } } @@ -66,11 +65,7 @@ object DownloadManager { return DownloadStatus( if (downloader == null || downloadQueue.none { it.state == Downloading } - ) { - "Stopped" - } else { - "Started" - }, + ) "Stopped" else "Started", downloadQueue ) } @@ -101,10 +96,8 @@ object DownloadManager { } fun start() { - if (downloader != null && !downloader?.isAlive!!) { - // doesn't exist or is dead + if (downloader != null && !downloader?.isAlive!!) // doesn't exist or is dead downloader = null - } if (downloader == null) { downloader = Downloader(downloadQueue) { notifyAllClients() } @@ -134,5 +127,5 @@ object DownloadManager { enum class DownloaderState(val state: Int) { Stopped(0), Running(1), - Paused(2) + Paused(2), } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt index f101150b6..087463d39 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadChapter.kt @@ -18,5 +18,5 @@ class DownloadChapter( var manga: MangaDataClass, var state: DownloadState = Queued, var progress: Float = 0f, - var tries: Int = 0 + var tries: Int = 0, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt index 5be5d609e..61ef7d11b 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadState.kt @@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) { Queued(0), Downloading(1), Finished(2), - Error(3) + Error(3), } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt index c2f748afb..8768813c0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/model/DownloadStatus.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model data class DownloadStatus( val status: String, - val queue: List + val queue: List, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt index 4a8f248f8..ae49f6946 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt @@ -225,13 +225,12 @@ object Extension { SourceTable.deleteWhere { SourceTable.extension eq extensionId } - if (extensionRecord[ExtensionTable.isObsolete]) { + if (extensionRecord[ExtensionTable.isObsolete]) ExtensionTable.deleteWhere { ExtensionTable.pkgName eq pkgName } - } else { + else ExtensionTable.update({ ExtensionTable.pkgName eq pkgName }) { it[isInstalled] = false } - } sources } @@ -266,11 +265,8 @@ object Extension { } suspend fun getExtensionIcon(apkName: String, useCache: Boolean): Pair { - val iconUrl = if (apkName == "localSource") { - "" - } else { - transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] - } + val iconUrl = if (apkName == "localSource") "" + else transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] val saveDir = "${applicationDirs.extensionsRoot}/icon" diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt index 82cca9f9d..cbdeac1d9 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt @@ -59,7 +59,7 @@ object ExtensionsList { it[ExtensionTable.isNsfw], it[ExtensionTable.isInstalled], it[ExtensionTable.hasUpdate], - it[ExtensionTable.isObsolete] + it[ExtensionTable.isObsolete], ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt index 45c8c7208..537d25c42 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt @@ -31,7 +31,7 @@ object ExtensionGithubApi { val nsfw: Int, val hasReadme: Int = 0, val hasChangelog: Int = 0, - val sources: List? + val sources: List?, ) @Serializable diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt index cafa504c0..69d901c54 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt @@ -32,8 +32,7 @@ object UpdaterSocket : Websocket() { |Supported commands are: | - STATUS | sends the current update status - | - """.trimMargin() + |""".trimMargin() ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt index 0deeaa2cf..59d0a8617 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt @@ -67,9 +67,7 @@ object BytecodeEditor { } path to bytes - } else { - null - } + } else null } catch (e: Exception) { logger.error(e) { "Error loading class from Path: $path" } null @@ -174,11 +172,7 @@ object BytecodeEditor { ): MethodVisitor { logger.trace { "Processing method $name: ${desc.replaceIndirectly()}: $signature" } val mv: MethodVisitor? = super.visitMethod( - access, - name, - desc.replaceIndirectly(), - signature, - exceptions + access, name, desc.replaceIndirectly(), signature, exceptions ) return object : MethodVisitor(Opcodes.ASM5, mv) { override fun visitLdcInsn(cst: Any?) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt index f19f0f63f..a49fad044 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt @@ -60,9 +60,7 @@ fun updateMangaDownloadDir(mangaId: Int, newTitle: String): Boolean { val oldDirFile = File(oldDir) val newDirFile = File(newDir) - return if (oldDirFile.exists()) { + return if (oldDirFile.exists()) oldDirFile.renameTo(newDirFile) - } else { - true - } + else true } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt index 5b07e817e..896a0daaa 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/lang/RxCoroutineBridge.kt @@ -37,13 +37,11 @@ private suspend fun Observable.awaitOne(): T = suspendCancellableCoroutin } override fun onCompleted() { - if (cont.isActive) { - cont.resumeWithException( - IllegalStateException( - "Should have invoked onNext" - ) + if (cont.isActive) cont.resumeWithException( + IllegalStateException( + "Should have invoked onNext" ) - } + ) } override fun onError(e: Throwable) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt index 2c8d9cc14..f782adc3b 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/storage/ImageResponse.kt @@ -21,9 +21,8 @@ object ImageResponse { fun findFileNameStartingWith(directoryPath: String, fileName: String): String? { val target = "$fileName." File(directoryPath).listFiles().orEmpty().forEach { file -> - if (file.name.startsWith(target)) { + if (file.name.startsWith(target)) return "$directoryPath/${file.name}" - } } return null } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt index e996358d7..a60730223 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ChapterDataClass.kt @@ -44,5 +44,5 @@ data class ChapterDataClass( val chapterCount: Int? = null, /** used to store client specific values */ - val meta: Map = emptyMap() + val meta: Map = emptyMap(), ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt index f3db7b72e..af8506533 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/ExtensionDataClass.kt @@ -20,5 +20,5 @@ data class ExtensionDataClass( val installed: Boolean, val hasUpdate: Boolean, - val obsolete: Boolean + val obsolete: Boolean, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt index 54d763e8e..c76298843 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/MangaChapterDataClass.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass data class MangaChapterDataClass( val manga: MangaDataClass, - val chapter: ChapterDataClass + val chapter: ChapterDataClass, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt index 0687e14bf..48cfbc65f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PageDataClass.kt @@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass data class PageDataClass( val index: Int, - var imageUrl: String + var imageUrl: String, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt index 7deefd65c..4a38a9167 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/PaginatedList.kt @@ -11,7 +11,7 @@ import kotlin.math.min open class PaginatedList( val page: List, - val hasNextPage: Boolean + val hasNextPage: Boolean, ) const val PaginationFactor = 50 diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt index ca9e6a2f1..7aefb7e2d 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/dataclass/SourceDataClass.kt @@ -25,5 +25,5 @@ data class SourceDataClass( val isNsfw: Boolean, /** A nicer version of [name] */ - val displayName: String + val displayName: String, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt index 0bcc0fd22..c00f7cad2 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/CategoryTable.kt @@ -21,5 +21,5 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass( categoryEntry[this.id].value, categoryEntry[order], categoryEntry[name], - categoryEntry[isDefault] + categoryEntry[isDefault], ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt index 19bc49f7a..47d704d68 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt @@ -53,5 +53,5 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) = chapterEntry[isDownloaded], chapterEntry[pageCount], transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() }, - getChapterMetaMap(chapterEntry[id]) + getChapterMetaMap(chapterEntry[id]), ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt index 4a3798d88..cba2c39b6 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/MangaTable.kt @@ -59,7 +59,7 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) = mangaEntry[inLibrary], mangaEntry[inLibraryAt], meta = getMangaMetaMap(mangaEntry[id].value), - realUrl = mangaEntry[realUrl] + realUrl = mangaEntry[realUrl], ) enum class MangaStatus(val value: Int) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt index e5c04e03a..d10a7afc5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt @@ -85,7 +85,7 @@ fun applicationSetup() { applicationDirs.extensionsRoot + "/icon", applicationDirs.thumbnailsRoot, applicationDirs.mangaDownloadsRoot, - applicationDirs.localMangaRoot + applicationDirs.localMangaRoot, ).forEach { File(it).mkdirs() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt index ce0384720..6837268e1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0001_Initial.kt @@ -13,8 +13,8 @@ import org.jetbrains.exposed.dao.id.IdTable import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.Table -/** initial migration, create all tables */ @Suppress("ClassName", "unused") +/** initial migration, create all tables */ class M0001_Initial : AddTableMigration() { private class ExtensionTable : IntIdTable() { init { @@ -128,7 +128,7 @@ class M0001_Initial : AddTableMigration() { chapterTable, pageTable, categoryTable, - categoryMangaTable + categoryMangaTable, ) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt index 9be9429be..fbf57385a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0011_SourceDropPartOfFactorySource.kt @@ -12,5 +12,5 @@ import de.neonew.exposed.migrations.helpers.DropColumnMigration @Suppress("ClassName", "unused") class M0011_SourceDropPartOfFactorySource : DropColumnMigration( "Source", - "part_of_factory_source" + "part_of_factory_source", ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt index bb20559e0..d72ce6663 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/DocumentationDsl.kt @@ -242,7 +242,7 @@ inline fun handler( it, getParam(it, param1), getParam(it, param2), - getParam(it, param3) + getParam(it, param3), ) } ) @@ -265,7 +265,7 @@ inline fun handler( getParam(it, param1), getParam(it, param2), getParam(it, param3), - getParam(it, param4) + getParam(it, param4), ) } ) @@ -290,7 +290,7 @@ inline fun handler( getParam(it, param2), getParam(it, param3), getParam(it, param4), - getParam(it, param5) + getParam(it, param5), ) } ) @@ -317,7 +317,7 @@ inline fun >)[0]), FilterObject("CheckBox", (source.mFilterList[6].state as List>)[1]), - FilterObject("CheckBox", (source.mFilterList[6].state as List>)[2]) + FilterObject("CheckBox", (source.mFilterList[6].state as List>)[2]), ) ) ) diff --git a/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt b/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt index c6b6dd6f6..a429c3bb6 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/manga/model/PaginatedListTest.kt @@ -31,7 +31,7 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor - 1), false), - paginated + paginated, ) } @@ -43,14 +43,14 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage + firstPage, ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false), - secondPage + secondPage, ) } @@ -62,14 +62,14 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage + firstPage, ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false), - secondPage + secondPage, ) } @@ -81,21 +81,21 @@ class PaginatedListTest : ApplicationTest() { assertEquals( PaginatedList(listIndicesOf(0, PaginationFactor), true), - firstPage + firstPage, ) val secondPage = paginatedFrom(1, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true), - secondPage + secondPage, ) val thirdPage = paginatedFrom(2, lister = masterLister) assertEquals( PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false), - thirdPage + thirdPage, ) } diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt index 69171a190..486832090 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt @@ -76,7 +76,7 @@ open class ApplicationTest { applicationDirs.extensionsRoot + "/icon", applicationDirs.thumbnailsRoot, applicationDirs.mangaDownloadsRoot, - applicationDirs.localMangaRoot + applicationDirs.localMangaRoot, ).forEach { File(it).mkdirs() } diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt index d6b827374..dffbe8b1f 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt @@ -23,9 +23,7 @@ fun setLoggingEnabled(enabled: Boolean = true) { val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger) logger.level = if (enabled) { Level.DEBUG - } else { - Level.ERROR - } + } else Level.ERROR } const val BASE_PATH = "build/tmp/TestDesk"