mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-30 21:17:50 +02:00
Ignore non-existent galleries during favorites sync
This commit is contained in:
@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.online.all.EHentai
|
||||
import eu.kanade.tachiyomi.util.syncChaptersWithSource
|
||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||
import okhttp3.MediaType
|
||||
@ -186,6 +187,11 @@ class GalleryAdder {
|
||||
return GalleryAddEvent.Success(url, manga)
|
||||
} catch(e: Exception) {
|
||||
XLog.w("Could not add gallery!", e)
|
||||
|
||||
if(e is EHentai.GalleryNotFoundException) {
|
||||
return GalleryAddEvent.Fail.NotFound(url)
|
||||
}
|
||||
|
||||
return GalleryAddEvent.Fail.Error(url,
|
||||
((e.message ?: "Unknown error!") + " (Gallery: $url)").trim())
|
||||
}
|
||||
@ -223,7 +229,10 @@ sealed class GalleryAddEvent {
|
||||
override val logMessage = "Unknown gallery type for gallery: $galleryUrl"
|
||||
}
|
||||
|
||||
class Error(override val galleryUrl: String,
|
||||
open class Error(override val galleryUrl: String,
|
||||
override val logMessage: String): Fail()
|
||||
|
||||
class NotFound(galleryUrl: String):
|
||||
Error(galleryUrl, "Gallery does not exist: $galleryUrl")
|
||||
}
|
||||
}
|
@ -323,6 +323,12 @@ class FavoritesSyncHelper(val context: Context) {
|
||||
EXH_SOURCE_ID)
|
||||
|
||||
if(result is GalleryAddEvent.Fail) {
|
||||
if(result is GalleryAddEvent.Fail.NotFound) {
|
||||
XLog.e("Remote gallery does not exist, skipping: %s!", it.getUrl())
|
||||
// Skip this gallery, it no longer exists
|
||||
return@forEachIndexed
|
||||
}
|
||||
|
||||
val errorString = "Failed to add gallery to local database: " + when (result) {
|
||||
is GalleryAddEvent.Fail.Error -> "'${it.title}' ${result.logMessage}"
|
||||
is GalleryAddEvent.Fail.UnknownType -> "'${it.title}' (${result.galleryUrl}) is not a valid gallery!"
|
||||
|
@ -43,7 +43,6 @@ class BatchAddPresenter: BasePresenter<BatchAddController>() {
|
||||
eventRelay?.call((when (result) {
|
||||
is GalleryAddEvent.Success -> "[OK]"
|
||||
is GalleryAddEvent.Fail -> "[ERROR]"
|
||||
else -> "[???]"
|
||||
}) + " " + result.logMessage)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user