From 5ef1b4ac9c55477161f97c1a5154d55a275f4a37 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 4 May 2024 17:20:42 +0300 Subject: [PATCH] Fix restoring bookmarks --- .../kotatsu/details/domain/DetailsLoadUseCase.kt | 2 +- .../main/domain/CoverRestoreInterceptor.kt | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/domain/DetailsLoadUseCase.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/domain/DetailsLoadUseCase.kt index 5c1e92d63..fc696db6c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/domain/DetailsLoadUseCase.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/domain/DetailsLoadUseCase.kt @@ -54,7 +54,7 @@ class DetailsLoadUseCase @Inject constructor( send(MangaDetails(manga, null, null, false)) try { val details = getDetails(manga) - launch { updateTracker(manga) } + launch { updateTracker(details) } send(MangaDetails(details, local?.peek(), details.description?.parseAsHtml(withImages = false), false)) send(MangaDetails(details, local?.await(), details.description?.parseAsHtml(withImages = true), true)) } catch (e: IOException) { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt index 11f34a6c2..1f09d1920 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt @@ -5,6 +5,7 @@ import coil.intercept.Interceptor import coil.network.HttpException import coil.request.ErrorResult import coil.request.ImageResult +import okio.FileNotFoundException import org.jsoup.HttpStatusException import org.koitharu.kotatsu.bookmarks.domain.Bookmark import org.koitharu.kotatsu.bookmarks.domain.BookmarksRepository @@ -13,11 +14,14 @@ import org.koitharu.kotatsu.core.parser.MangaDataRepository import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.parser.RemoteMangaRepository import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty +import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.parsers.exception.ParseException import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.util.runCatchingCancellable +import java.net.UnknownHostException import java.util.Collections import javax.inject.Inject +import javax.net.ssl.SSLException class CoverRestoreInterceptor @Inject constructor( private val dataRepository: MangaDataRepository, @@ -56,6 +60,8 @@ class CoverRestoreInterceptor @Inject constructor( } val restored = runCatchingCancellable { restoreMangaImpl(manga) + }.onFailure { e -> + e.printStackTraceDebug() }.getOrDefault(false) if (restored) { blacklist.remove(key) @@ -84,6 +90,8 @@ class CoverRestoreInterceptor @Inject constructor( } val restored = runCatchingCancellable { restoreBookmarkImpl(bookmark) + }.onFailure { e -> + e.printStackTraceDebug() }.getOrDefault(false) if (restored) { blacklist.remove(key) @@ -105,6 +113,11 @@ class CoverRestoreInterceptor @Inject constructor( } private fun Throwable.shouldRestore(): Boolean { - return this is HttpException || this is HttpStatusException || this is ParseException + return this is HttpException + || this is HttpStatusException + || this is SSLException + || this is ParseException + || this is UnknownHostException + || this is FileNotFoundException } }