mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-11 23:04:33 -05:00
Lint (#423)
This commit is contained in:
@@ -41,7 +41,9 @@ object Category {
|
||||
normalizeCategories()
|
||||
|
||||
newCategoryId
|
||||
} else -1
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -78,7 +78,7 @@ object Search {
|
||||
|
||||
data class FilterObject(
|
||||
val type: String,
|
||||
val filter: Filter<*>,
|
||||
val filter: Filter<*>
|
||||
)
|
||||
|
||||
fun setFilter(sourceId: Long, changes: List<FilterChange>) {
|
||||
|
||||
@@ -48,7 +48,7 @@ object Source {
|
||||
catalogueSource.supportsLatest,
|
||||
catalogueSource is ConfigurableSource,
|
||||
it[SourceTable.isNsfw],
|
||||
catalogueSource.toString(),
|
||||
catalogueSource.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ data class BackupFlags(
|
||||
val includeCategories: Boolean,
|
||||
val includeChapters: Boolean,
|
||||
val includeTracking: Boolean,
|
||||
val includeHistory: Boolean,
|
||||
val includeHistory: Boolean
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ data class Backup(
|
||||
@ProtoNumber(2) var backupCategories: List<BackupCategory> = emptyList(),
|
||||
// Bump by 100 to specify this is a 0.x value
|
||||
@ProtoNumber(100) var brokenBackupSources: List<BrokenBackupSource> = emptyList(),
|
||||
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList(),
|
||||
@ProtoNumber(101) var backupSources: List<BackupSource> = emptyList()
|
||||
) {
|
||||
fun getSourceMap(): Map<Long, String> {
|
||||
return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -35,7 +35,7 @@ data class BackupManga(
|
||||
@ProtoNumber(101) var chapterFlags: Int = 0,
|
||||
@ProtoNumber(102) var brokenHistory: List<BrokenBackupHistory> = emptyList(),
|
||||
@ProtoNumber(103) var viewer_flags: Int? = null,
|
||||
@ProtoNumber(104) var history: List<BackupHistory> = emptyList(),
|
||||
@ProtoNumber(104) var history: List<BackupHistory> = emptyList()
|
||||
) {
|
||||
fun getMangaImpl(): MangaImpl {
|
||||
return MangaImpl().apply {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -37,7 +37,6 @@ private class ChapterForDownload(
|
||||
private val mangaId: Int
|
||||
) {
|
||||
suspend fun asDownloadReady(): ChapterDataClass {
|
||||
|
||||
if (isNotCompletelyDownloaded()) {
|
||||
markAsNotDownloaded()
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) {
|
||||
Queued(0),
|
||||
Downloading(1),
|
||||
Finished(2),
|
||||
Error(3),
|
||||
Error(3)
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model
|
||||
|
||||
data class DownloadStatus(
|
||||
val status: String,
|
||||
val queue: List<DownloadChapter>,
|
||||
val queue: List<DownloadChapter>
|
||||
)
|
||||
|
||||
@@ -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<InputStream, String> {
|
||||
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"
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ object ExtensionsList {
|
||||
it[ExtensionTable.isNsfw],
|
||||
it[ExtensionTable.isInstalled],
|
||||
it[ExtensionTable.hasUpdate],
|
||||
it[ExtensionTable.isObsolete],
|
||||
it[ExtensionTable.isObsolete]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ object ExtensionGithubApi {
|
||||
val nsfw: Int,
|
||||
val hasReadme: Int = 0,
|
||||
val hasChangelog: Int = 0,
|
||||
val sources: List<ExtensionSourceJsonObject>?,
|
||||
val sources: List<ExtensionSourceJsonObject>?
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -32,7 +32,8 @@ object UpdaterSocket : Websocket<UpdateStatus>() {
|
||||
|Supported commands are:
|
||||
| - STATUS
|
||||
| sends the current update status
|
||||
|""".trimMargin()
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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?) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,13 @@ private suspend fun <T> Observable<T>.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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user