mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-11 23:04:33 -05:00
Fix/invalid server settings gql mutation request (#1092)
* Validate setting values on mutation * Handle invalid negative setting values * Ensure at least one source is downloading at all times * Prevent possible IllegalArgumentException The "serverConfig.maxSourcesInParallel" value could have changed after the if-condition
This commit is contained in:
@@ -400,7 +400,7 @@ object Chapter {
|
||||
if (serverConfig.autoDownloadNewChaptersLimit.value == 0) {
|
||||
chaptersToConsiderForDownloadLimit.size
|
||||
} else {
|
||||
serverConfig.autoDownloadNewChaptersLimit.value.coerceAtMost(chaptersToConsiderForDownloadLimit.size)
|
||||
serverConfig.autoDownloadNewChaptersLimit.value.coerceIn(0, chaptersToConsiderForDownloadLimit.size)
|
||||
}
|
||||
val limitedChaptersToDownload = chaptersToConsiderForDownloadLimit.subList(0, latestChapterToDownloadIndex)
|
||||
val limitedChaptersToDownloadWithDuplicates =
|
||||
|
||||
@@ -241,14 +241,14 @@ object DownloadManager {
|
||||
"Failed: ${downloadQueue.size - availableDownloads.size}"
|
||||
}
|
||||
|
||||
if (runningDownloaders.size < serverConfig.maxSourcesInParallel.value) {
|
||||
if (runningDownloaders.size < serverConfig.maxSourcesInParallel.value.coerceAtLeast(1)) {
|
||||
availableDownloads
|
||||
.asSequence()
|
||||
.map { it.manga.sourceId }
|
||||
.distinct()
|
||||
.minus(
|
||||
runningDownloaders.map { it.sourceId }.toSet(),
|
||||
).take(serverConfig.maxSourcesInParallel.value - runningDownloaders.size)
|
||||
).take((serverConfig.maxSourcesInParallel.value - runningDownloaders.size).coerceAtLeast(0))
|
||||
.map { getDownloader(it) }
|
||||
.forEach {
|
||||
it.start()
|
||||
|
||||
@@ -224,7 +224,7 @@ object ExtensionsList {
|
||||
this
|
||||
}
|
||||
|
||||
private val repoMatchRegex =
|
||||
val repoMatchRegex =
|
||||
(
|
||||
"https:\\/\\/(?>www\\.|raw\\.)?(github|githubusercontent)\\.com" +
|
||||
"\\/([^\\/]+)\\/([^\\/]+)(?>(?>\\/tree|\\/blob)?\\/([^\\/\\n]*))?(?>\\/([^\\/\\n]*\\.json)?)?"
|
||||
|
||||
Reference in New Issue
Block a user