mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 02:49:18 +01:00
Ignore failures when updating metadata as part of library update
This commit is contained in:
parent
3ee652b61a
commit
58860b51a2
@ -35,6 +35,7 @@ import eu.kanade.tachiyomi.util.system.acquireWakeLock
|
|||||||
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
import eu.kanade.tachiyomi.util.system.createFileInCacheDir
|
||||||
import eu.kanade.tachiyomi.util.system.isServiceRunning
|
import eu.kanade.tachiyomi.util.system.isServiceRunning
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@ -195,20 +196,18 @@ class LibraryUpdateService(
|
|||||||
val mangaList = getMangaToUpdate(intent, target)
|
val mangaList = getMangaToUpdate(intent, target)
|
||||||
.sortedWith(rankingScheme[selectedScheme])
|
.sortedWith(rankingScheme[selectedScheme])
|
||||||
|
|
||||||
updateJob = ioScope.launch {
|
val handler = CoroutineExceptionHandler { _, exception ->
|
||||||
try {
|
Timber.e(exception)
|
||||||
when (target) {
|
stopSelf(startId)
|
||||||
Target.CHAPTERS -> updateChapterList(mangaList)
|
}
|
||||||
Target.COVERS -> updateCovers(mangaList)
|
updateJob = ioScope.launch(handler) {
|
||||||
Target.TRACKING -> updateTrackings(mangaList)
|
when (target) {
|
||||||
}
|
Target.CHAPTERS -> updateChapterList(mangaList)
|
||||||
} catch (e: Throwable) {
|
Target.COVERS -> updateCovers(mangaList)
|
||||||
Timber.e(e)
|
Target.TRACKING -> updateTrackings(mangaList)
|
||||||
stopSelf(startId)
|
|
||||||
} finally {
|
|
||||||
stopSelf(startId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateJob?.invokeOnCompletion { stopSelf(startId) }
|
||||||
|
|
||||||
return START_REDELIVER_INTENT
|
return START_REDELIVER_INTENT
|
||||||
}
|
}
|
||||||
@ -335,17 +334,22 @@ class LibraryUpdateService(
|
|||||||
// Update manga details metadata in the background
|
// Update manga details metadata in the background
|
||||||
if (preferences.autoUpdateMetadata()) {
|
if (preferences.autoUpdateMetadata()) {
|
||||||
GlobalScope.launchIO {
|
GlobalScope.launchIO {
|
||||||
val updatedManga = source.getMangaDetails(manga.toMangaInfo())
|
try {
|
||||||
val sManga = updatedManga.toSManga()
|
val updatedManga = source.getMangaDetails(manga.toMangaInfo())
|
||||||
// Avoid "losing" existing cover
|
val sManga = updatedManga.toSManga()
|
||||||
if (!sManga.thumbnail_url.isNullOrEmpty()) {
|
// Avoid "losing" existing cover
|
||||||
manga.prepUpdateCover(coverCache, sManga, false)
|
if (!sManga.thumbnail_url.isNullOrEmpty()) {
|
||||||
} else {
|
manga.prepUpdateCover(coverCache, sManga, false)
|
||||||
sManga.thumbnail_url = manga.thumbnail_url
|
} else {
|
||||||
}
|
sManga.thumbnail_url = manga.thumbnail_url
|
||||||
|
}
|
||||||
|
|
||||||
manga.copyFrom(sManga)
|
manga.copyFrom(sManga)
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
// Ignore errors and continue
|
||||||
|
Timber.e(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user