Skip to content

Commit 6e291c1

Browse files
FlaminSargecuong-tran
authored andcommitted
Attempt to fix crash when migrating or removing entries from library (mihonapp/mihon#1828)
Co-authored-by: Cuong-Tran <[email protected]> Co-authored-by: AntsyLich <[email protected]> (cherry picked from commit 563bc02113a5ebc53650fdfdd13f408284a0cdc8)
1 parent 870d77e commit 6e291c1

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
3838
- Fix backup/restore of category related preferences ([@cuong-tran](https://github.com/cuong-tran)) ([#1726](https://github.com/mihonapp/mihon/pull/1726))
3939
- Fix WebView sending app's package name in `X-Requested-With` header, which led to sources blocking access ([@AwkwardPeak7](https://github.com/AwkwardPeak7)) ([#1812](https://github.com/mihonapp/mihon/pull/1812))
4040
- Fix an issue where tracker reading progress is changed to a lower value ([@Animeboynz](https://github.com/Animeboynz)) ([#1795](https://github.com/mihonapp/mihon/pull/1795))
41+
- Attempt to fix crash when migrating or removing entries from library ([@FlaminSarge](https://github.com/FlaminSarge)) ([#1828](https://github.com/mihonapp/mihon/pull/1828))
4142

4243
### Removed
4344
- Remove alphabetical category sort option

domain/src/main/java/tachiyomi/domain/manga/interactor/GetFavorites.kt

+18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package tachiyomi.domain.manga.interactor
22

3+
import kotlinx.coroutines.delay
34
import kotlinx.coroutines.flow.Flow
5+
import kotlinx.coroutines.flow.catch
6+
import kotlinx.coroutines.flow.retry
7+
import logcat.LogPriority
8+
import tachiyomi.core.common.util.system.logcat
49
import tachiyomi.domain.manga.model.Manga
510
import tachiyomi.domain.manga.repository.MangaRepository
11+
import kotlin.time.Duration.Companion.seconds
612

713
class GetFavorites(
814
private val mangaRepository: MangaRepository,
@@ -14,5 +20,17 @@ class GetFavorites(
1420

1521
fun subscribe(sourceId: Long): Flow<List<Manga>> {
1622
return mangaRepository.getFavoritesBySourceId(sourceId)
23+
// KMK -->
24+
.retry {
25+
if (it is NullPointerException) {
26+
delay(0.5.seconds)
27+
true
28+
} else {
29+
false
30+
}
31+
}.catch {
32+
this@GetFavorites.logcat(LogPriority.ERROR, it)
33+
}
34+
// KMK <--
1735
}
1836
}

domain/src/main/java/tachiyomi/domain/manga/interactor/GetLibraryManga.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package tachiyomi.domain.manga.interactor
22

33
import kotlinx.coroutines.delay
44
import kotlinx.coroutines.flow.Flow
5+
import kotlinx.coroutines.flow.catch
56
import kotlinx.coroutines.flow.retry
7+
import logcat.LogPriority
8+
import tachiyomi.core.common.util.system.logcat
69
import tachiyomi.domain.library.model.LibraryManga
710
import tachiyomi.domain.manga.repository.MangaRepository
811
import kotlin.time.Duration.Companion.seconds
@@ -17,15 +20,15 @@ class GetLibraryManga(
1720

1821
fun subscribe(): Flow<List<LibraryManga>> {
1922
return mangaRepository.getLibraryMangaAsFlow()
20-
// SY -->
2123
.retry {
2224
if (it is NullPointerException) {
23-
delay(5.seconds)
25+
delay(0.5.seconds)
2426
true
2527
} else {
2628
false
2729
}
30+
}.catch {
31+
this@GetLibraryManga.logcat(LogPriority.ERROR, it)
2832
}
29-
// SY <--
3033
}
3134
}

domain/src/main/java/tachiyomi/domain/updates/interactor/GetUpdates.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ package tachiyomi.domain.updates.interactor
22

33
import kotlinx.coroutines.delay
44
import kotlinx.coroutines.flow.Flow
5+
import kotlinx.coroutines.flow.catch
56
import kotlinx.coroutines.flow.first
67
import kotlinx.coroutines.flow.flow
78
import kotlinx.coroutines.flow.retry
9+
import logcat.LogPriority
10+
import tachiyomi.core.common.util.system.logcat
811
import tachiyomi.domain.updates.model.UpdatesWithRelations
912
import tachiyomi.domain.updates.repository.UpdatesRepository
1013
import java.time.Instant
@@ -41,11 +44,13 @@ class GetUpdates(
4144
// SY -->
4245
private fun <T> Flow<T>.catchNPE() = retry {
4346
if (it is NullPointerException) {
44-
delay(5.seconds)
47+
delay(0.5.seconds)
4548
true
4649
} else {
4750
false
4851
}
52+
}.catch {
53+
this@GetUpdates.logcat(LogPriority.ERROR, it)
4954
}
5055
// SY <--
5156
}

0 commit comments

Comments
 (0)