|
@@ -21,6 +21,7 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Companion.start
|
|
|
import eu.kanade.tachiyomi.data.notification.Notifications
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
|
|
+import eu.kanade.tachiyomi.data.track.TrackService
|
|
|
import eu.kanade.tachiyomi.data.track.UnattendedTrackService
|
|
|
import eu.kanade.tachiyomi.source.SourceManager
|
|
|
import eu.kanade.tachiyomi.source.model.SManga
|
|
@@ -273,6 +274,7 @@ class LibraryUpdateService(
|
|
|
val newUpdates = mutableListOf<Pair<LibraryManga, Array<Chapter>>>()
|
|
|
val failedUpdates = mutableListOf<Pair<Manga, String?>>()
|
|
|
var hasDownloads = false
|
|
|
+ val loggedServices by lazy { trackManager.services.filter { it.isLogged } }
|
|
|
|
|
|
mangaToUpdate.forEach { manga ->
|
|
|
if (updateJob?.isActive != true) {
|
|
@@ -301,6 +303,10 @@ class LibraryUpdateService(
|
|
|
}
|
|
|
failedUpdates.add(manga to errorMessage)
|
|
|
}
|
|
|
+
|
|
|
+ if (preferences.autoUpdateTrackers()) {
|
|
|
+ updateTrackings(manga, loggedServices)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
notifier.cancelProgressNotification()
|
|
@@ -409,31 +415,35 @@ class LibraryUpdateService(
|
|
|
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
|
|
|
|
|
// Update the tracking details.
|
|
|
- db.getTracks(manga).executeAsBlocking()
|
|
|
- .map { track ->
|
|
|
- supervisorScope {
|
|
|
- async {
|
|
|
- val service = trackManager.getService(track.sync_id)
|
|
|
- if (service != null && service in loggedServices) {
|
|
|
- try {
|
|
|
- val updatedTrack = service.refresh(track)
|
|
|
- db.insertTrack(updatedTrack).executeAsBlocking()
|
|
|
-
|
|
|
- if (service is UnattendedTrackService) {
|
|
|
- syncChaptersWithTrackServiceTwoWay(db, db.getChapters(manga).executeAsBlocking(), track, service)
|
|
|
- }
|
|
|
- } catch (e: Throwable) {
|
|
|
- // Ignore errors and continue
|
|
|
- Timber.e(e)
|
|
|
+ updateTrackings(manga, loggedServices)
|
|
|
+ }
|
|
|
+
|
|
|
+ notifier.cancelProgressNotification()
|
|
|
+ }
|
|
|
+
|
|
|
+ private suspend fun updateTrackings(manga: LibraryManga, loggedServices: List<TrackService>) {
|
|
|
+ db.getTracks(manga).executeAsBlocking()
|
|
|
+ .map { track ->
|
|
|
+ supervisorScope {
|
|
|
+ async {
|
|
|
+ val service = trackManager.getService(track.sync_id)
|
|
|
+ if (service != null && service in loggedServices) {
|
|
|
+ try {
|
|
|
+ val updatedTrack = service.refresh(track)
|
|
|
+ db.insertTrack(updatedTrack).executeAsBlocking()
|
|
|
+
|
|
|
+ if (service is UnattendedTrackService) {
|
|
|
+ syncChaptersWithTrackServiceTwoWay(db, db.getChapters(manga).executeAsBlocking(), track, service)
|
|
|
}
|
|
|
+ } catch (e: Throwable) {
|
|
|
+ // Ignore errors and continue
|
|
|
+ Timber.e(e)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .awaitAll()
|
|
|
- }
|
|
|
-
|
|
|
- notifier.cancelProgressNotification()
|
|
|
+ }
|
|
|
+ .awaitAll()
|
|
|
}
|
|
|
|
|
|
/**
|