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:
@@ -60,9 +60,13 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun internalMove(row: Int) {
|
private fun internalMove(row: Int) {
|
||||||
if (cursor < 0) cursor = 0
|
if (cursor < 0) {
|
||||||
else if (cursor > resultSetLength + 1) cursor = resultSetLength + 1
|
cursor = 0
|
||||||
else cursor = row
|
} else if (cursor > resultSetLength + 1) {
|
||||||
|
cursor = resultSetLength + 1
|
||||||
|
} else {
|
||||||
|
cursor = row
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun obj(column: Int): Any? {
|
private fun obj(column: Int): Any? {
|
||||||
@@ -293,11 +297,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun <T : Any?> unwrap(iface: Class<T>?): T {
|
override fun <T : Any?> unwrap(iface: Class<T>?): T {
|
||||||
if (thisIsWrapperFor(iface))
|
if (thisIsWrapperFor(iface)) {
|
||||||
return this as T
|
return this as T
|
||||||
else
|
} else {
|
||||||
return parent.unwrap(iface)
|
return parent.unwrap(iface)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun next(): Boolean {
|
override fun next(): Boolean {
|
||||||
internalMove(cursor + 1)
|
internalMove(cursor + 1)
|
||||||
@@ -531,10 +536,15 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun castToLong(obj: Any?): Long {
|
private fun castToLong(obj: Any?): Long {
|
||||||
if (obj == null) return 0
|
if (obj == null) {
|
||||||
else if (obj is Long) return obj
|
return 0
|
||||||
else if (obj is Number) return obj.toLong()
|
} else if (obj is Long) {
|
||||||
else throw IllegalStateException("Object is not a 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 {
|
override fun getLong(columnIndex: Int): Long {
|
||||||
|
|||||||
@@ -74,11 +74,12 @@ class PackageController {
|
|||||||
|
|
||||||
fun findPackage(packageName: String): InstalledPackage? {
|
fun findPackage(packageName: String): InstalledPackage? {
|
||||||
val file = File(androidFiles.packagesDir, packageName)
|
val file = File(androidFiles.packagesDir, packageName)
|
||||||
return if (file.exists())
|
return if (file.exists()) {
|
||||||
InstalledPackage(file)
|
InstalledPackage(file)
|
||||||
else
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun findJarFromApk(apkFile: File): File? {
|
fun findJarFromApk(apkFile: File): File? {
|
||||||
val pkgName = ApkParsers.getMetaInfo(apkFile).packageName
|
val pkgName = ApkParsers.getMetaInfo(apkFile).packageName
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import uy.kohesive.injekt.api.get
|
|||||||
class AppModule(val app: Application) : InjektModule {
|
class AppModule(val app: Application) : InjektModule {
|
||||||
|
|
||||||
override fun InjektRegistrar.registerInjectables() {
|
override fun InjektRegistrar.registerInjectables() {
|
||||||
|
|
||||||
addSingleton(app)
|
addSingleton(app)
|
||||||
|
|
||||||
// addSingletonFactory { PreferencesHelper(app) }
|
// addSingletonFactory { PreferencesHelper(app) }
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ import java.util.concurrent.TimeUnit
|
|||||||
fun OkHttpClient.Builder.rateLimit(
|
fun OkHttpClient.Builder.rateLimit(
|
||||||
permits: Int,
|
permits: Int,
|
||||||
period: Long = 1,
|
period: Long = 1,
|
||||||
unit: TimeUnit = TimeUnit.SECONDS,
|
unit: TimeUnit = TimeUnit.SECONDS
|
||||||
) = addInterceptor(RateLimitInterceptor(permits, period, unit))
|
) = addInterceptor(RateLimitInterceptor(permits, period, unit))
|
||||||
|
|
||||||
private class RateLimitInterceptor(
|
private class RateLimitInterceptor(
|
||||||
private val permits: Int,
|
private val permits: Int,
|
||||||
period: Long,
|
period: Long,
|
||||||
unit: TimeUnit,
|
unit: TimeUnit
|
||||||
) : Interceptor {
|
) : Interceptor {
|
||||||
|
|
||||||
private val requestQueue = ArrayList<Long>(permits)
|
private val requestQueue = ArrayList<Long>(permits)
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ fun OkHttpClient.Builder.rateLimitHost(
|
|||||||
httpUrl: HttpUrl,
|
httpUrl: HttpUrl,
|
||||||
permits: Int,
|
permits: Int,
|
||||||
period: Long = 1,
|
period: Long = 1,
|
||||||
unit: TimeUnit = TimeUnit.SECONDS,
|
unit: TimeUnit = TimeUnit.SECONDS
|
||||||
) = addInterceptor(SpecificHostRateLimitInterceptor(httpUrl, permits, period, unit))
|
) = addInterceptor(SpecificHostRateLimitInterceptor(httpUrl, permits, period, unit))
|
||||||
|
|
||||||
class SpecificHostRateLimitInterceptor(
|
class SpecificHostRateLimitInterceptor(
|
||||||
httpUrl: HttpUrl,
|
httpUrl: HttpUrl,
|
||||||
private val permits: Int,
|
private val permits: Int,
|
||||||
period: Long,
|
period: Long,
|
||||||
unit: TimeUnit,
|
unit: TimeUnit
|
||||||
) : Interceptor {
|
) : Interceptor {
|
||||||
|
|
||||||
private val requestQueue = ArrayList<Long>(permits)
|
private val requestQueue = ArrayList<Long>(permits)
|
||||||
|
|||||||
@@ -327,8 +327,9 @@ class LocalSource : CatalogueSource {
|
|||||||
|
|
||||||
fun getFormat(chapter: SChapter): Format {
|
fun getFormat(chapter: SChapter): Format {
|
||||||
val chapFile = File(applicationDirs.localMangaRoot, chapter.url)
|
val chapFile = File(applicationDirs.localMangaRoot, chapter.url)
|
||||||
if (chapFile.exists())
|
if (chapFile.exists()) {
|
||||||
return getFormat(chapFile)
|
return getFormat(chapFile)
|
||||||
|
}
|
||||||
|
|
||||||
throw Exception("Chapter not found")
|
throw Exception("Chapter not found")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ data class AboutDataClass(
|
|||||||
val buildType: String,
|
val buildType: String,
|
||||||
val buildTime: Long,
|
val buildTime: Long,
|
||||||
val github: String,
|
val github: String,
|
||||||
val discord: String,
|
val discord: String
|
||||||
)
|
)
|
||||||
|
|
||||||
object About {
|
object About {
|
||||||
@@ -28,7 +28,7 @@ object About {
|
|||||||
BuildConfig.BUILD_TYPE,
|
BuildConfig.BUILD_TYPE,
|
||||||
BuildConfig.BUILD_TIME,
|
BuildConfig.BUILD_TIME,
|
||||||
BuildConfig.GITHUB,
|
BuildConfig.GITHUB,
|
||||||
BuildConfig.DISCORD,
|
BuildConfig.DISCORD
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ object AppUpdate {
|
|||||||
UpdateDataClass(
|
UpdateDataClass(
|
||||||
"Stable",
|
"Stable",
|
||||||
stableJson["tag_name"]!!.jsonPrimitive.content,
|
stableJson["tag_name"]!!.jsonPrimitive.content,
|
||||||
stableJson["html_url"]!!.jsonPrimitive.content,
|
stableJson["html_url"]!!.jsonPrimitive.content
|
||||||
),
|
),
|
||||||
UpdateDataClass(
|
UpdateDataClass(
|
||||||
"Preview",
|
"Preview",
|
||||||
previewJson["tag_name"]!!.jsonPrimitive.content,
|
previewJson["tag_name"]!!.jsonPrimitive.content,
|
||||||
previewJson["html_url"]!!.jsonPrimitive.content,
|
previewJson["html_url"]!!.jsonPrimitive.content
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ object BackupController {
|
|||||||
includeCategories = true,
|
includeCategories = true,
|
||||||
includeChapters = true,
|
includeChapters = true,
|
||||||
includeTracking = true,
|
includeTracking = true,
|
||||||
includeHistory = true,
|
includeHistory = true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ object BackupController {
|
|||||||
includeCategories = true,
|
includeCategories = true,
|
||||||
includeChapters = true,
|
includeChapters = true,
|
||||||
includeTracking = true,
|
includeTracking = true,
|
||||||
includeHistory = true,
|
includeHistory = true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ object Category {
|
|||||||
normalizeCategories()
|
normalizeCategories()
|
||||||
|
|
||||||
newCategoryId
|
newCategoryId
|
||||||
} else -1
|
} else {
|
||||||
|
-1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,13 +86,14 @@ object CategoryManga {
|
|||||||
dataClass
|
dataClass
|
||||||
}
|
}
|
||||||
|
|
||||||
if (categoryId == DEFAULT_CATEGORY_ID)
|
if (categoryId == DEFAULT_CATEGORY_ID) {
|
||||||
return transaction {
|
return transaction {
|
||||||
MangaTable
|
MangaTable
|
||||||
.slice(selectedColumns)
|
.slice(selectedColumns)
|
||||||
.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }
|
.select { (MangaTable.inLibrary eq true) and (MangaTable.defaultCategory eq true) }
|
||||||
.map(transform)
|
.map(transform)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return transaction {
|
return transaction {
|
||||||
CategoryMangaTable.innerJoin(MangaTable)
|
CategoryMangaTable.innerJoin(MangaTable)
|
||||||
|
|||||||
@@ -45,11 +45,12 @@ import java.io.InputStream
|
|||||||
|
|
||||||
object Manga {
|
object Manga {
|
||||||
private fun truncate(text: String?, maxLength: Int): String? {
|
private fun truncate(text: String?, maxLength: Int): String? {
|
||||||
return if (text?.length ?: 0 > maxLength)
|
return if (text?.length ?: 0 > maxLength) {
|
||||||
text?.take(maxLength - 3) + "..."
|
text?.take(maxLength - 3) + "..."
|
||||||
else
|
} else {
|
||||||
text
|
text
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun getManga(mangaId: Int, onlineFetch: Boolean = false): MangaDataClass {
|
suspend fun getManga(mangaId: Int, onlineFetch: Boolean = false): MangaDataClass {
|
||||||
var mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
var mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() }
|
||||||
@@ -68,13 +69,13 @@ object Manga {
|
|||||||
|
|
||||||
transaction {
|
transaction {
|
||||||
MangaTable.update({ MangaTable.id eq mangaId }) {
|
MangaTable.update({ MangaTable.id eq mangaId }) {
|
||||||
|
|
||||||
if (sManga.title != mangaEntry[MangaTable.title]) {
|
if (sManga.title != mangaEntry[MangaTable.title]) {
|
||||||
val canUpdateTitle = updateMangaDownloadDir(mangaId, sManga.title)
|
val canUpdateTitle = updateMangaDownloadDir(mangaId, sManga.title)
|
||||||
|
|
||||||
if (canUpdateTitle)
|
if (canUpdateTitle) {
|
||||||
it[MangaTable.title] = sManga.title
|
it[MangaTable.title] = sManga.title
|
||||||
}
|
}
|
||||||
|
}
|
||||||
it[MangaTable.initialized] = true
|
it[MangaTable.initialized] = true
|
||||||
|
|
||||||
it[MangaTable.artist] = sManga.artist
|
it[MangaTable.artist] = sManga.artist
|
||||||
@@ -82,8 +83,9 @@ object Manga {
|
|||||||
it[MangaTable.description] = truncate(sManga.description, 4096)
|
it[MangaTable.description] = truncate(sManga.description, 4096)
|
||||||
it[MangaTable.genre] = sManga.genre
|
it[MangaTable.genre] = sManga.genre
|
||||||
it[MangaTable.status] = sManga.status
|
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.thumbnail_url] = sManga.thumbnail_url
|
||||||
|
}
|
||||||
|
|
||||||
it[MangaTable.realUrl] = runCatching {
|
it[MangaTable.realUrl] = runCatching {
|
||||||
(source as? HttpSource)?.mangaDetailsRequest(sManga)?.url?.toString()
|
(source as? HttpSource)?.mangaDetailsRequest(sManga)?.url?.toString()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ object Search {
|
|||||||
|
|
||||||
data class FilterObject(
|
data class FilterObject(
|
||||||
val type: String,
|
val type: String,
|
||||||
val filter: Filter<*>,
|
val filter: Filter<*>
|
||||||
)
|
)
|
||||||
|
|
||||||
fun setFilter(sourceId: Long, changes: List<FilterChange>) {
|
fun setFilter(sourceId: Long, changes: List<FilterChange>) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ object Source {
|
|||||||
catalogueSource.supportsLatest,
|
catalogueSource.supportsLatest,
|
||||||
catalogueSource is ConfigurableSource,
|
catalogueSource is ConfigurableSource,
|
||||||
it[SourceTable.isNsfw],
|
it[SourceTable.isNsfw],
|
||||||
catalogueSource.toString(),
|
catalogueSource.toString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ data class BackupFlags(
|
|||||||
val includeCategories: Boolean,
|
val includeCategories: Boolean,
|
||||||
val includeChapters: Boolean,
|
val includeChapters: Boolean,
|
||||||
val includeTracking: Boolean,
|
val includeTracking: Boolean,
|
||||||
val includeHistory: Boolean,
|
val includeHistory: Boolean
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
|||||||
MangaStatus.valueOf(mangaRow[MangaTable.status]).value,
|
MangaStatus.valueOf(mangaRow[MangaTable.status]).value,
|
||||||
mangaRow[MangaTable.thumbnail_url],
|
mangaRow[MangaTable.thumbnail_url],
|
||||||
TimeUnit.SECONDS.toMillis(mangaRow[MangaTable.inLibraryAt]),
|
TimeUnit.SECONDS.toMillis(mangaRow[MangaTable.inLibraryAt]),
|
||||||
0, // not supported in Tachidesk
|
0 // not supported in Tachidesk
|
||||||
)
|
)
|
||||||
|
|
||||||
val mangaId = mangaRow[MangaTable.id].value
|
val mangaId = mangaRow[MangaTable.id].value
|
||||||
@@ -94,7 +94,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
|||||||
TimeUnit.SECONDS.toMillis(it.fetchedAt),
|
TimeUnit.SECONDS.toMillis(it.fetchedAt),
|
||||||
it.uploadDate,
|
it.uploadDate,
|
||||||
it.chapterNumber,
|
it.chapterNumber,
|
||||||
chapters.size - it.index,
|
chapters.size - it.index
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
|||||||
BackupCategory(
|
BackupCategory(
|
||||||
it.name,
|
it.name,
|
||||||
it.order,
|
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(),
|
@ProtoNumber(2) var backupCategories: List<BackupCategory> = emptyList(),
|
||||||
// Bump by 100 to specify this is a 0.x value
|
// Bump by 100 to specify this is a 0.x value
|
||||||
@ProtoNumber(100) var brokenBackupSources: List<BrokenBackupSource> = emptyList(),
|
@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> {
|
fun getSourceMap(): Map<Long, String> {
|
||||||
return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources)
|
return (brokenBackupSources.map { BackupSource(it.name, it.sourceId) } + backupSources)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class BackupCategory(
|
|||||||
@ProtoNumber(2) var order: Int = 0,
|
@ProtoNumber(2) var order: Int = 0,
|
||||||
// @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x
|
// @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
|
// 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 {
|
fun getCategoryImpl(): CategoryImpl {
|
||||||
return CategoryImpl().apply {
|
return CategoryImpl().apply {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ data class BackupChapter(
|
|||||||
@ProtoNumber(8) var dateUpload: Long = 0,
|
@ProtoNumber(8) var dateUpload: Long = 0,
|
||||||
// chapterNumber is called number is 1.x
|
// chapterNumber is called number is 1.x
|
||||||
@ProtoNumber(9) var chapterNumber: Float = 0F,
|
@ProtoNumber(9) var chapterNumber: Float = 0F,
|
||||||
@ProtoNumber(10) var sourceOrder: Int = 0,
|
@ProtoNumber(10) var sourceOrder: Int = 0
|
||||||
) {
|
) {
|
||||||
fun toChapterImpl(): ChapterImpl {
|
fun toChapterImpl(): ChapterImpl {
|
||||||
return ChapterImpl().apply {
|
return ChapterImpl().apply {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ data class BackupManga(
|
|||||||
@ProtoNumber(101) var chapterFlags: Int = 0,
|
@ProtoNumber(101) var chapterFlags: Int = 0,
|
||||||
@ProtoNumber(102) var brokenHistory: List<BrokenBackupHistory> = emptyList(),
|
@ProtoNumber(102) var brokenHistory: List<BrokenBackupHistory> = emptyList(),
|
||||||
@ProtoNumber(103) var viewer_flags: Int? = null,
|
@ProtoNumber(103) var viewer_flags: Int? = null,
|
||||||
@ProtoNumber(104) var history: List<BackupHistory> = emptyList(),
|
@ProtoNumber(104) var history: List<BackupHistory> = emptyList()
|
||||||
) {
|
) {
|
||||||
fun getMangaImpl(): MangaImpl {
|
fun getMangaImpl(): MangaImpl {
|
||||||
return MangaImpl().apply {
|
return MangaImpl().apply {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ data class BackupTracking(
|
|||||||
// startedReadingDate is called startReadTime in 1.x
|
// startedReadingDate is called startReadTime in 1.x
|
||||||
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
||||||
// finishedReadingDate is called endReadTime in 1.x
|
// finishedReadingDate is called endReadTime in 1.x
|
||||||
@ProtoNumber(11) var finishedReadingDate: Long = 0,
|
@ProtoNumber(11) var finishedReadingDate: Long = 0
|
||||||
) {
|
) {
|
||||||
fun getTrackingImpl(): TrackImpl {
|
fun getTrackingImpl(): TrackImpl {
|
||||||
return TrackImpl().apply {
|
return TrackImpl().apply {
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ private class ChapterForDownload(
|
|||||||
private val mangaId: Int
|
private val mangaId: Int
|
||||||
) {
|
) {
|
||||||
suspend fun asDownloadReady(): ChapterDataClass {
|
suspend fun asDownloadReady(): ChapterDataClass {
|
||||||
|
|
||||||
if (isNotCompletelyDownloaded()) {
|
if (isNotCompletelyDownloaded()) {
|
||||||
markAsNotDownloaded()
|
markAsNotDownloaded()
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ object DownloadManager {
|
|||||||
|Supported commands are:
|
|Supported commands are:
|
||||||
| - STATUS
|
| - STATUS
|
||||||
| sends the current download status
|
| sends the current download status
|
||||||
|""".trimMargin()
|
|
|
||||||
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,11 @@ object DownloadManager {
|
|||||||
return DownloadStatus(
|
return DownloadStatus(
|
||||||
if (downloader == null ||
|
if (downloader == null ||
|
||||||
downloadQueue.none { it.state == Downloading }
|
downloadQueue.none { it.state == Downloading }
|
||||||
) "Stopped" else "Started",
|
) {
|
||||||
|
"Stopped"
|
||||||
|
} else {
|
||||||
|
"Started"
|
||||||
|
},
|
||||||
downloadQueue
|
downloadQueue
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -96,8 +101,10 @@ object DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun start() {
|
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
|
downloader = null
|
||||||
|
}
|
||||||
|
|
||||||
if (downloader == null) {
|
if (downloader == null) {
|
||||||
downloader = Downloader(downloadQueue) { notifyAllClients() }
|
downloader = Downloader(downloadQueue) { notifyAllClients() }
|
||||||
@@ -127,5 +134,5 @@ object DownloadManager {
|
|||||||
enum class DownloaderState(val state: Int) {
|
enum class DownloaderState(val state: Int) {
|
||||||
Stopped(0),
|
Stopped(0),
|
||||||
Running(1),
|
Running(1),
|
||||||
Paused(2),
|
Paused(2)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ class DownloadChapter(
|
|||||||
var manga: MangaDataClass,
|
var manga: MangaDataClass,
|
||||||
var state: DownloadState = Queued,
|
var state: DownloadState = Queued,
|
||||||
var progress: Float = 0f,
|
var progress: Float = 0f,
|
||||||
var tries: Int = 0,
|
var tries: Int = 0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ enum class DownloadState(val state: Int) {
|
|||||||
Queued(0),
|
Queued(0),
|
||||||
Downloading(1),
|
Downloading(1),
|
||||||
Finished(2),
|
Finished(2),
|
||||||
Error(3),
|
Error(3)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.impl.download.model
|
|||||||
|
|
||||||
data class DownloadStatus(
|
data class DownloadStatus(
|
||||||
val status: String,
|
val status: String,
|
||||||
val queue: List<DownloadChapter>,
|
val queue: List<DownloadChapter>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -225,12 +225,13 @@ object Extension {
|
|||||||
|
|
||||||
SourceTable.deleteWhere { SourceTable.extension eq extensionId }
|
SourceTable.deleteWhere { SourceTable.extension eq extensionId }
|
||||||
|
|
||||||
if (extensionRecord[ExtensionTable.isObsolete])
|
if (extensionRecord[ExtensionTable.isObsolete]) {
|
||||||
ExtensionTable.deleteWhere { ExtensionTable.pkgName eq pkgName }
|
ExtensionTable.deleteWhere { ExtensionTable.pkgName eq pkgName }
|
||||||
else
|
} else {
|
||||||
ExtensionTable.update({ ExtensionTable.pkgName eq pkgName }) {
|
ExtensionTable.update({ ExtensionTable.pkgName eq pkgName }) {
|
||||||
it[isInstalled] = false
|
it[isInstalled] = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sources
|
sources
|
||||||
}
|
}
|
||||||
@@ -265,8 +266,11 @@ object Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getExtensionIcon(apkName: String, useCache: Boolean): Pair<InputStream, String> {
|
suspend fun getExtensionIcon(apkName: String, useCache: Boolean): Pair<InputStream, String> {
|
||||||
val iconUrl = if (apkName == "localSource") ""
|
val iconUrl = if (apkName == "localSource") {
|
||||||
else transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
""
|
||||||
|
} else {
|
||||||
|
transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl]
|
||||||
|
}
|
||||||
|
|
||||||
val saveDir = "${applicationDirs.extensionsRoot}/icon"
|
val saveDir = "${applicationDirs.extensionsRoot}/icon"
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ object ExtensionsList {
|
|||||||
it[ExtensionTable.isNsfw],
|
it[ExtensionTable.isNsfw],
|
||||||
it[ExtensionTable.isInstalled],
|
it[ExtensionTable.isInstalled],
|
||||||
it[ExtensionTable.hasUpdate],
|
it[ExtensionTable.hasUpdate],
|
||||||
it[ExtensionTable.isObsolete],
|
it[ExtensionTable.isObsolete]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ object ExtensionGithubApi {
|
|||||||
val nsfw: Int,
|
val nsfw: Int,
|
||||||
val hasReadme: Int = 0,
|
val hasReadme: Int = 0,
|
||||||
val hasChangelog: Int = 0,
|
val hasChangelog: Int = 0,
|
||||||
val sources: List<ExtensionSourceJsonObject>?,
|
val sources: List<ExtensionSourceJsonObject>?
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ object UpdaterSocket : Websocket<UpdateStatus>() {
|
|||||||
|Supported commands are:
|
|Supported commands are:
|
||||||
| - STATUS
|
| - STATUS
|
||||||
| sends the current update status
|
| sends the current update status
|
||||||
|""".trimMargin()
|
|
|
||||||
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ object BytecodeEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path to bytes
|
path to bytes
|
||||||
} else null
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error(e) { "Error loading class from Path: $path" }
|
logger.error(e) { "Error loading class from Path: $path" }
|
||||||
null
|
null
|
||||||
@@ -172,7 +174,11 @@ object BytecodeEditor {
|
|||||||
): MethodVisitor {
|
): MethodVisitor {
|
||||||
logger.trace { "Processing method $name: ${desc.replaceIndirectly()}: $signature" }
|
logger.trace { "Processing method $name: ${desc.replaceIndirectly()}: $signature" }
|
||||||
val mv: MethodVisitor? = super.visitMethod(
|
val mv: MethodVisitor? = super.visitMethod(
|
||||||
access, name, desc.replaceIndirectly(), signature, exceptions
|
access,
|
||||||
|
name,
|
||||||
|
desc.replaceIndirectly(),
|
||||||
|
signature,
|
||||||
|
exceptions
|
||||||
)
|
)
|
||||||
return object : MethodVisitor(Opcodes.ASM5, mv) {
|
return object : MethodVisitor(Opcodes.ASM5, mv) {
|
||||||
override fun visitLdcInsn(cst: Any?) {
|
override fun visitLdcInsn(cst: Any?) {
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ fun updateMangaDownloadDir(mangaId: Int, newTitle: String): Boolean {
|
|||||||
val oldDirFile = File(oldDir)
|
val oldDirFile = File(oldDir)
|
||||||
val newDirFile = File(newDir)
|
val newDirFile = File(newDir)
|
||||||
|
|
||||||
return if (oldDirFile.exists())
|
return if (oldDirFile.exists()) {
|
||||||
oldDirFile.renameTo(newDirFile)
|
oldDirFile.renameTo(newDirFile)
|
||||||
else true
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,14 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCompleted() {
|
override fun onCompleted() {
|
||||||
if (cont.isActive) cont.resumeWithException(
|
if (cont.isActive) {
|
||||||
|
cont.resumeWithException(
|
||||||
IllegalStateException(
|
IllegalStateException(
|
||||||
"Should have invoked onNext"
|
"Should have invoked onNext"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ object ImageResponse {
|
|||||||
fun findFileNameStartingWith(directoryPath: String, fileName: String): String? {
|
fun findFileNameStartingWith(directoryPath: String, fileName: String): String? {
|
||||||
val target = "$fileName."
|
val target = "$fileName."
|
||||||
File(directoryPath).listFiles().orEmpty().forEach { file ->
|
File(directoryPath).listFiles().orEmpty().forEach { file ->
|
||||||
if (file.name.startsWith(target))
|
if (file.name.startsWith(target)) {
|
||||||
return "$directoryPath/${file.name}"
|
return "$directoryPath/${file.name}"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,5 +44,5 @@ data class ChapterDataClass(
|
|||||||
val chapterCount: Int? = null,
|
val chapterCount: Int? = null,
|
||||||
|
|
||||||
/** used to store client specific values */
|
/** used to store client specific values */
|
||||||
val meta: Map<String, String> = emptyMap(),
|
val meta: Map<String, String> = emptyMap()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,5 +20,5 @@ data class ExtensionDataClass(
|
|||||||
|
|
||||||
val installed: Boolean,
|
val installed: Boolean,
|
||||||
val hasUpdate: Boolean,
|
val hasUpdate: Boolean,
|
||||||
val obsolete: Boolean,
|
val obsolete: Boolean
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
|
|||||||
|
|
||||||
data class MangaChapterDataClass(
|
data class MangaChapterDataClass(
|
||||||
val manga: MangaDataClass,
|
val manga: MangaDataClass,
|
||||||
val chapter: ChapterDataClass,
|
val chapter: ChapterDataClass
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ package suwayomi.tachidesk.manga.model.dataclass
|
|||||||
|
|
||||||
data class PageDataClass(
|
data class PageDataClass(
|
||||||
val index: Int,
|
val index: Int,
|
||||||
var imageUrl: String,
|
var imageUrl: String
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import kotlin.math.min
|
|||||||
|
|
||||||
open class PaginatedList<T>(
|
open class PaginatedList<T>(
|
||||||
val page: List<T>,
|
val page: List<T>,
|
||||||
val hasNextPage: Boolean,
|
val hasNextPage: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
const val PaginationFactor = 50
|
const val PaginationFactor = 50
|
||||||
|
|||||||
@@ -25,5 +25,5 @@ data class SourceDataClass(
|
|||||||
val isNsfw: Boolean,
|
val isNsfw: Boolean,
|
||||||
|
|
||||||
/** A nicer version of [name] */
|
/** A nicer version of [name] */
|
||||||
val displayName: String,
|
val displayName: String
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ fun CategoryTable.toDataClass(categoryEntry: ResultRow) = CategoryDataClass(
|
|||||||
categoryEntry[this.id].value,
|
categoryEntry[this.id].value,
|
||||||
categoryEntry[order],
|
categoryEntry[order],
|
||||||
categoryEntry[name],
|
categoryEntry[name],
|
||||||
categoryEntry[isDefault],
|
categoryEntry[isDefault]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -53,5 +53,5 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) =
|
|||||||
chapterEntry[isDownloaded],
|
chapterEntry[isDownloaded],
|
||||||
chapterEntry[pageCount],
|
chapterEntry[pageCount],
|
||||||
transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() },
|
transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() },
|
||||||
getChapterMetaMap(chapterEntry[id]),
|
getChapterMetaMap(chapterEntry[id])
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
|
|||||||
mangaEntry[inLibrary],
|
mangaEntry[inLibrary],
|
||||||
mangaEntry[inLibraryAt],
|
mangaEntry[inLibraryAt],
|
||||||
meta = getMangaMetaMap(mangaEntry[id].value),
|
meta = getMangaMetaMap(mangaEntry[id].value),
|
||||||
realUrl = mangaEntry[realUrl],
|
realUrl = mangaEntry[realUrl]
|
||||||
)
|
)
|
||||||
|
|
||||||
enum class MangaStatus(val value: Int) {
|
enum class MangaStatus(val value: Int) {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ fun applicationSetup() {
|
|||||||
applicationDirs.extensionsRoot + "/icon",
|
applicationDirs.extensionsRoot + "/icon",
|
||||||
applicationDirs.thumbnailsRoot,
|
applicationDirs.thumbnailsRoot,
|
||||||
applicationDirs.mangaDownloadsRoot,
|
applicationDirs.mangaDownloadsRoot,
|
||||||
applicationDirs.localMangaRoot,
|
applicationDirs.localMangaRoot
|
||||||
).forEach {
|
).forEach {
|
||||||
File(it).mkdirs()
|
File(it).mkdirs()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import org.jetbrains.exposed.dao.id.IdTable
|
|||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||||
import org.jetbrains.exposed.sql.Table
|
import org.jetbrains.exposed.sql.Table
|
||||||
|
|
||||||
@Suppress("ClassName", "unused")
|
|
||||||
/** initial migration, create all tables */
|
/** initial migration, create all tables */
|
||||||
|
@Suppress("ClassName", "unused")
|
||||||
class M0001_Initial : AddTableMigration() {
|
class M0001_Initial : AddTableMigration() {
|
||||||
private class ExtensionTable : IntIdTable() {
|
private class ExtensionTable : IntIdTable() {
|
||||||
init {
|
init {
|
||||||
@@ -128,7 +128,7 @@ class M0001_Initial : AddTableMigration() {
|
|||||||
chapterTable,
|
chapterTable,
|
||||||
pageTable,
|
pageTable,
|
||||||
categoryTable,
|
categoryTable,
|
||||||
categoryMangaTable,
|
categoryMangaTable
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ import de.neonew.exposed.migrations.helpers.DropColumnMigration
|
|||||||
@Suppress("ClassName", "unused")
|
@Suppress("ClassName", "unused")
|
||||||
class M0011_SourceDropPartOfFactorySource : DropColumnMigration(
|
class M0011_SourceDropPartOfFactorySource : DropColumnMigration(
|
||||||
"Source",
|
"Source",
|
||||||
"part_of_factory_source",
|
"part_of_factory_source"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ inline fun <reified P1, reified P2, reified P3> handler(
|
|||||||
it,
|
it,
|
||||||
getParam(it, param1),
|
getParam(it, param1),
|
||||||
getParam(it, param2),
|
getParam(it, param2),
|
||||||
getParam(it, param3),
|
getParam(it, param3)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -265,7 +265,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4> handler(
|
|||||||
getParam(it, param1),
|
getParam(it, param1),
|
||||||
getParam(it, param2),
|
getParam(it, param2),
|
||||||
getParam(it, param3),
|
getParam(it, param3),
|
||||||
getParam(it, param4),
|
getParam(it, param4)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -290,7 +290,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5> handler(
|
|||||||
getParam(it, param2),
|
getParam(it, param2),
|
||||||
getParam(it, param3),
|
getParam(it, param3),
|
||||||
getParam(it, param4),
|
getParam(it, param4),
|
||||||
getParam(it, param5),
|
getParam(it, param5)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -317,7 +317,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
|
|||||||
getParam(it, param3),
|
getParam(it, param3),
|
||||||
getParam(it, param4),
|
getParam(it, param4),
|
||||||
getParam(it, param5),
|
getParam(it, param5),
|
||||||
getParam(it, param6),
|
getParam(it, param6)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -346,7 +346,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
|
|||||||
getParam(it, param4),
|
getParam(it, param4),
|
||||||
getParam(it, param5),
|
getParam(it, param5),
|
||||||
getParam(it, param6),
|
getParam(it, param6),
|
||||||
getParam(it, param7),
|
getParam(it, param7)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -377,7 +377,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
|
|||||||
getParam(it, param5),
|
getParam(it, param5),
|
||||||
getParam(it, param6),
|
getParam(it, param6),
|
||||||
getParam(it, param7),
|
getParam(it, param7),
|
||||||
getParam(it, param8),
|
getParam(it, param8)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -410,7 +410,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
|
|||||||
getParam(it, param6),
|
getParam(it, param6),
|
||||||
getParam(it, param7),
|
getParam(it, param7),
|
||||||
getParam(it, param8),
|
getParam(it, param8),
|
||||||
getParam(it, param9),
|
getParam(it, param9)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -445,7 +445,7 @@ inline fun <reified P1, reified P2, reified P3, reified P4, reified P5, reified
|
|||||||
getParam(it, param7),
|
getParam(it, param7),
|
||||||
getParam(it, param8),
|
getParam(it, param8),
|
||||||
getParam(it, param9),
|
getParam(it, param9),
|
||||||
getParam(it, param10),
|
getParam(it, param10)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -103,8 +103,9 @@ fun setupWebUI() {
|
|||||||
while (true) {
|
while (true) {
|
||||||
val count = inp.read(data, 0, 1024)
|
val count = inp.read(data, 0, 1024)
|
||||||
|
|
||||||
if (count == -1)
|
if (count == -1) {
|
||||||
break
|
break
|
||||||
|
}
|
||||||
|
|
||||||
totalCount += count
|
totalCount += count
|
||||||
val percentage = (totalCount.toFloat() / contentLength * 100).toInt().toString().padStart(2, '0')
|
val percentage = (totalCount.toFloat() / contentLength * 100).toInt().toString().padStart(2, '0')
|
||||||
|
|||||||
@@ -31,12 +31,14 @@ class CategoryMangaTest : ApplicationTest() {
|
|||||||
createChapters(mangaId, 10, true)
|
createChapters(mangaId, 10, true)
|
||||||
assertEquals(1, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size, "Default category should have one member")
|
assertEquals(1, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size, "Default category should have one member")
|
||||||
assertEquals(
|
assertEquals(
|
||||||
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
|
0,
|
||||||
|
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
|
||||||
"Manga should not have any unread chapters"
|
"Manga should not have any unread chapters"
|
||||||
)
|
)
|
||||||
createChapters(mangaId, 10, false)
|
createChapters(mangaId, 10, false)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
10, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
|
10,
|
||||||
|
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID)[0].unreadCount,
|
||||||
"Manga should have unread chapters"
|
"Manga should have unread chapters"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -48,15 +50,18 @@ class CategoryMangaTest : ApplicationTest() {
|
|||||||
)
|
)
|
||||||
CategoryManga.addMangaToCategory(mangaId, categoryId)
|
CategoryManga.addMangaToCategory(mangaId, categoryId)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
1, CategoryManga.getCategoryMangaList(categoryId).size,
|
1,
|
||||||
|
CategoryManga.getCategoryMangaList(categoryId).size,
|
||||||
"Manga should been moved"
|
"Manga should been moved"
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
10, CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
|
10,
|
||||||
|
CategoryManga.getCategoryMangaList(categoryId)[0].unreadCount,
|
||||||
"Manga should keep it's unread count in moved category"
|
"Manga should keep it's unread count in moved category"
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
0, CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
|
0,
|
||||||
|
CategoryManga.getCategoryMangaList(DEFAULT_CATEGORY_ID).size,
|
||||||
"Manga shouldn't be member of default category after moving"
|
"Manga shouldn't be member of default category after moving"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,17 +36,20 @@ class MangaTest : ApplicationTest() {
|
|||||||
"Manga meta should still only have one pair"
|
"Manga meta should still only have one pair"
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"newValue", Manga.getMangaMetaMap(metaManga)["test"],
|
"newValue",
|
||||||
|
Manga.getMangaMetaMap(metaManga)["test"],
|
||||||
"Manga meta with key 'test' should use the value `newValue`"
|
"Manga meta with key 'test' should use the value `newValue`"
|
||||||
)
|
)
|
||||||
|
|
||||||
Manga.modifyMangaMeta(metaManga, "test2", "value2")
|
Manga.modifyMangaMeta(metaManga, "test2", "value2")
|
||||||
assertEquals(
|
assertEquals(
|
||||||
2, Manga.getMangaMetaMap(metaManga).size,
|
2,
|
||||||
|
Manga.getMangaMetaMap(metaManga).size,
|
||||||
"Manga Meta should have an additional pair"
|
"Manga Meta should have an additional pair"
|
||||||
)
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"value2", Manga.getMangaMetaMap(metaManga)["test2"],
|
"value2",
|
||||||
|
Manga.getMangaMetaMap(metaManga)["test2"],
|
||||||
"Manga Meta for key 'test2' should be 'value2'"
|
"Manga Meta for key 'test2' should be 'value2'"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ class FilterListTest : ApplicationTest() {
|
|||||||
val filterList = getFilterList(source.id, false)
|
val filterList = getFilterList(source.id, false)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
0, filterList.size
|
0,
|
||||||
|
filterList.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +112,7 @@ class FilterListTest : ApplicationTest() {
|
|||||||
listOf(
|
listOf(
|
||||||
TestCheckBox("Write Tests"),
|
TestCheckBox("Write Tests"),
|
||||||
TestCheckBox("Write More Tests"),
|
TestCheckBox("Write More Tests"),
|
||||||
TestCheckBox("Write Even More Tests"),
|
TestCheckBox("Write Even More Tests")
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Sort(
|
Sort(
|
||||||
@@ -160,7 +161,7 @@ class FilterListTest : ApplicationTest() {
|
|||||||
listOf(
|
listOf(
|
||||||
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[0]),
|
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[0]),
|
||||||
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[1]),
|
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[1]),
|
||||||
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2]),
|
FilterObject("CheckBox", (source.mFilterList[6].state as List<Filter<*>>)[2])
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class PaginatedListTest : ApplicationTest() {
|
|||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(0, PaginationFactor - 1), false),
|
PaginatedList(listIndicesOf(0, PaginationFactor - 1), false),
|
||||||
paginated,
|
paginated
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,14 +43,14 @@ class PaginatedListTest : ApplicationTest() {
|
|||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
||||||
firstPage,
|
firstPage
|
||||||
)
|
)
|
||||||
|
|
||||||
val secondPage = paginatedFrom(1, lister = masterLister)
|
val secondPage = paginatedFrom(1, lister = masterLister)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false),
|
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2 - 1), false),
|
||||||
secondPage,
|
secondPage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,14 +62,14 @@ class PaginatedListTest : ApplicationTest() {
|
|||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
||||||
firstPage,
|
firstPage
|
||||||
)
|
)
|
||||||
|
|
||||||
val secondPage = paginatedFrom(1, lister = masterLister)
|
val secondPage = paginatedFrom(1, lister = masterLister)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false),
|
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), false),
|
||||||
secondPage,
|
secondPage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,21 +81,21 @@ class PaginatedListTest : ApplicationTest() {
|
|||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
PaginatedList(listIndicesOf(0, PaginationFactor), true),
|
||||||
firstPage,
|
firstPage
|
||||||
)
|
)
|
||||||
|
|
||||||
val secondPage = paginatedFrom(1, lister = masterLister)
|
val secondPage = paginatedFrom(1, lister = masterLister)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true),
|
PaginatedList(listIndicesOf(PaginationFactor, PaginationFactor * 2), true),
|
||||||
secondPage,
|
secondPage
|
||||||
)
|
)
|
||||||
|
|
||||||
val thirdPage = paginatedFrom(2, lister = masterLister)
|
val thirdPage = paginatedFrom(2, lister = masterLister)
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false),
|
PaginatedList(listIndicesOf(PaginationFactor * 2, PaginationFactor * 2 + 1), false),
|
||||||
thirdPage,
|
thirdPage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ open class ApplicationTest {
|
|||||||
applicationDirs.extensionsRoot + "/icon",
|
applicationDirs.extensionsRoot + "/icon",
|
||||||
applicationDirs.thumbnailsRoot,
|
applicationDirs.thumbnailsRoot,
|
||||||
applicationDirs.mangaDownloadsRoot,
|
applicationDirs.mangaDownloadsRoot,
|
||||||
applicationDirs.localMangaRoot,
|
applicationDirs.localMangaRoot
|
||||||
).forEach {
|
).forEach {
|
||||||
File(it).mkdirs()
|
File(it).mkdirs()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ fun setLoggingEnabled(enabled: Boolean = true) {
|
|||||||
val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
|
val logger = (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
|
||||||
logger.level = if (enabled) {
|
logger.level = if (enabled) {
|
||||||
Level.DEBUG
|
Level.DEBUG
|
||||||
} else Level.ERROR
|
} else {
|
||||||
|
Level.ERROR
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const val BASE_PATH = "build/tmp/TestDesk"
|
const val BASE_PATH = "build/tmp/TestDesk"
|
||||||
|
|||||||
Reference in New Issue
Block a user