mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 02:44:34 -05:00
* Set updater running flag to false only at the end of the update For clearing the data loader cache properly, the update status subscription requires the update to be running. For the last completed manga update the flag was immediately set to false which prevented the dataloader cache from getting cleared, returning outdated data for the last updated manga * Correctly clear the "MangaForIdsDataLoader" cache The cache keys for this dataloader are lists of manga ids. Thus, it is not possible to clear only the cached data of the provided manga id and instead each cache entry that includes the manga id has to be cleared * Ensure that manga dataloader caches gets cleared during global update The "StateFlow" drops value updates in case the collector is too slow, which was the case for the "UpdateSubscription". This caused the dataloader cache to not get properly cleared because the running state of the update was already set to false.
25 lines
789 B
Kotlin
25 lines
789 B
Kotlin
package suwayomi.tachidesk.graphql.queries
|
|
|
|
import kotlinx.coroutines.flow.first
|
|
import org.kodein.di.DI
|
|
import org.kodein.di.conf.global
|
|
import org.kodein.di.instance
|
|
import suwayomi.tachidesk.graphql.types.UpdateStatus
|
|
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
|
import java.util.concurrent.CompletableFuture
|
|
|
|
class UpdateQuery {
|
|
private val updater by DI.global.instance<IUpdater>()
|
|
|
|
fun updateStatus(): CompletableFuture<UpdateStatus> {
|
|
return future { UpdateStatus(updater.status.first()) }
|
|
}
|
|
|
|
data class LastUpdateTimestampPayload(val timestamp: Long)
|
|
|
|
fun lastUpdateTimestamp(): LastUpdateTimestampPayload {
|
|
return LastUpdateTimestampPayload(updater.getLastUpdateTimestamp())
|
|
}
|
|
}
|