Correctly calculate the first chapter to download index (#796)

Subtracting 1 from the first chapter to download index caused an additional chapter to get downloaded (e.g. limit 4 would download 5 chapters)

Regression was introduced with 05bf4f5525
This commit is contained in:
schroda
2023-12-23 22:23:06 +01:00
committed by GitHub
parent 11be969101
commit 621b4c0946
@@ -308,7 +308,6 @@ object Chapter {
")",
)
// convert numbers to be index based
val newNumberOfChapters = updatedChapterList.size
val numberOfNewChapters = newNumberOfChapters - prevNumberOfChapters
@@ -340,7 +339,7 @@ object Chapter {
val firstChapterToDownloadIndex =
if (serverConfig.autoDownloadAheadLimit.value > 0) {
(numberOfNewChapters - serverConfig.autoDownloadAheadLimit.value - 1).coerceAtLeast(0)
(numberOfNewChapters - serverConfig.autoDownloadAheadLimit.value).coerceAtLeast(0)
} else {
0
}