mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 20:01:50 +01:00
Set db chapter metadata from correct chapter (#7303)
This commit is contained in:
parent
fd5da2de3a
commit
a01c370d63
@ -85,28 +85,29 @@ class SyncChaptersWithSource(
|
|||||||
val dbChapter = dbChapters.find { it.url == chapter.url }
|
val dbChapter = dbChapters.find { it.url == chapter.url }
|
||||||
|
|
||||||
if (dbChapter == null) {
|
if (dbChapter == null) {
|
||||||
if (chapter.dateUpload == 0L) {
|
val toAddChapter = if (chapter.dateUpload == 0L) {
|
||||||
val altDateUpload = if (maxSeenUploadDate == 0L) rightNow else maxSeenUploadDate
|
val altDateUpload = if (maxSeenUploadDate == 0L) rightNow else maxSeenUploadDate
|
||||||
chapter = chapter.copy(dateUpload = altDateUpload)
|
chapter.copy(dateUpload = altDateUpload)
|
||||||
} else {
|
} else {
|
||||||
maxSeenUploadDate = max(maxSeenUploadDate, sourceChapter.dateUpload)
|
maxSeenUploadDate = max(maxSeenUploadDate, sourceChapter.dateUpload)
|
||||||
|
chapter
|
||||||
}
|
}
|
||||||
toAdd.add(chapter)
|
toAdd.add(toAddChapter)
|
||||||
} else {
|
} else {
|
||||||
if (shouldUpdateDbChapter.await(dbChapter, chapter)) {
|
if (shouldUpdateDbChapter.await(dbChapter, chapter)) {
|
||||||
if (dbChapter.name != chapter.name && downloadManager.isChapterDownloaded(dbChapter.toDbChapter(), manga.toDbManga())) {
|
if (dbChapter.name != chapter.name && downloadManager.isChapterDownloaded(dbChapter.toDbChapter(), manga.toDbManga())) {
|
||||||
downloadManager.renameChapter(source, manga.toDbManga(), dbChapter.toDbChapter(), chapter.toDbChapter())
|
downloadManager.renameChapter(source, manga.toDbManga(), dbChapter.toDbChapter(), chapter.toDbChapter())
|
||||||
}
|
}
|
||||||
chapter = dbChapter.copy(
|
var toChangeChapter = dbChapter.copy(
|
||||||
name = sourceChapter.name,
|
name = chapter.name,
|
||||||
chapterNumber = sourceChapter.chapterNumber,
|
chapterNumber = chapter.chapterNumber,
|
||||||
scanlator = sourceChapter.scanlator,
|
scanlator = chapter.scanlator,
|
||||||
sourceOrder = sourceChapter.sourceOrder,
|
sourceOrder = chapter.sourceOrder,
|
||||||
)
|
)
|
||||||
if (sourceChapter.dateUpload != 0L) {
|
if (chapter.dateUpload != 0L) {
|
||||||
chapter = chapter.copy(dateUpload = sourceChapter.dateUpload)
|
toChangeChapter = toChangeChapter.copy(dateUpload = chapter.dateUpload)
|
||||||
}
|
}
|
||||||
toChange.add(chapter)
|
toChange.add(toChangeChapter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,11 +134,10 @@ class SyncChaptersWithSource(
|
|||||||
|
|
||||||
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
||||||
// Sources MUST return the chapters from most to less recent, which is common.
|
// Sources MUST return the chapters from most to less recent, which is common.
|
||||||
val now = Date().time
|
|
||||||
|
|
||||||
var itemCount = toAdd.size
|
var itemCount = toAdd.size
|
||||||
var updatedToAdd = toAdd.map { toAddItem ->
|
var updatedToAdd = toAdd.map { toAddItem ->
|
||||||
var chapter = toAddItem.copy(dateFetch = now + itemCount--)
|
var chapter = toAddItem.copy(dateFetch = rightNow + itemCount--)
|
||||||
|
|
||||||
if (chapter.isRecognizedNumber.not() && chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
if (chapter.isRecognizedNumber.not() && chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user