mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 11:21:49 +01:00
ChapterSourceSync: set default timestamp to max timestamp (#7197)
(cherry picked from commit dd5da56695
)
This commit is contained in:
parent
c76a136d3f
commit
96d2fb62e4
@ -11,6 +11,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TreeSet
|
import java.util.TreeSet
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method for syncing the list of chapters from the source with the ones from the database.
|
* Helper method for syncing the list of chapters from the source with the ones from the database.
|
||||||
@ -59,6 +60,9 @@ fun syncChaptersWithSource(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var maxTimestamp = 0L // in previous chapters to add
|
||||||
|
val rightNow = Date().time
|
||||||
|
|
||||||
for (sourceChapter in sourceChapters) {
|
for (sourceChapter in sourceChapters) {
|
||||||
// This forces metadata update for the main viewable things in the chapter list.
|
// This forces metadata update for the main viewable things in the chapter list.
|
||||||
if (source is HttpSource) {
|
if (source is HttpSource) {
|
||||||
@ -72,7 +76,9 @@ fun syncChaptersWithSource(
|
|||||||
// Add the chapter if not in db already, or update if the metadata changed.
|
// Add the chapter if not in db already, or update if the metadata changed.
|
||||||
if (dbChapter == null) {
|
if (dbChapter == null) {
|
||||||
if (sourceChapter.date_upload == 0L) {
|
if (sourceChapter.date_upload == 0L) {
|
||||||
sourceChapter.date_upload = Date().time
|
sourceChapter.date_upload = if (maxTimestamp == 0L) rightNow else maxTimestamp
|
||||||
|
} else {
|
||||||
|
maxTimestamp = max(maxTimestamp, sourceChapter.date_upload)
|
||||||
}
|
}
|
||||||
toAdd.add(sourceChapter)
|
toAdd.add(sourceChapter)
|
||||||
} else {
|
} else {
|
||||||
@ -97,6 +103,7 @@ fun syncChaptersWithSource(
|
|||||||
return Pair(emptyList(), emptyList())
|
return Pair(emptyList(), emptyList())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep it a List instead of a Set. See #6372.
|
||||||
val readded = mutableListOf<Chapter>()
|
val readded = mutableListOf<Chapter>()
|
||||||
|
|
||||||
db.inTransaction {
|
db.inTransaction {
|
||||||
@ -154,6 +161,7 @@ fun syncChaptersWithSource(
|
|||||||
db.updateLastUpdated(manga).executeAsBlocking()
|
db.updateLastUpdated(manga).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("ConvertArgumentToSet")
|
||||||
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user