mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
better cleaning algorithm
This commit is contained in:
@@ -105,14 +105,13 @@ object Chapter {
|
|||||||
val dbChapterCount = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count() }
|
val dbChapterCount = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count() }
|
||||||
if (dbChapterCount > chapterCount) { // we got some clean up due
|
if (dbChapterCount > chapterCount) { // we got some clean up due
|
||||||
val dbChapterList = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.toList() }
|
val dbChapterList = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.toList() }
|
||||||
|
val chapterUrls = chapterList.map { it.url }.toSet()
|
||||||
|
|
||||||
dbChapterList.forEach {
|
dbChapterList.forEach { dbChapter ->
|
||||||
if (it[ChapterTable.sourceOrder] >= chapterList.size ||
|
if (!chapterUrls.contains(dbChapter[ChapterTable.url])) {
|
||||||
chapterList[it[ChapterTable.sourceOrder] - 1].url != it[ChapterTable.url]
|
|
||||||
) {
|
|
||||||
transaction {
|
transaction {
|
||||||
PageTable.deleteWhere { PageTable.chapter eq it[ChapterTable.id] }
|
PageTable.deleteWhere { PageTable.chapter eq dbChapter[ChapterTable.id] }
|
||||||
ChapterTable.deleteWhere { ChapterTable.id eq it[ChapterTable.id] }
|
ChapterTable.deleteWhere { ChapterTable.id eq dbChapter[ChapterTable.id] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user