From 08f6317bebb3ec566a70036f1268211ee4ccc6b1 Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 13 Jan 2018 11:47:04 +0100 Subject: [PATCH] Add error handling to migrations --- .../kanade/tachiyomi/ui/migration/MigrationPresenter.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MigrationPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MigrationPresenter.kt index 419e571a69..c17fbee8b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MigrationPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MigrationPresenter.kt @@ -85,7 +85,9 @@ class MigrationPresenter( state = state.copy(isReplacingManga = true) Observable.defer { source.fetchChapterList(manga) } + .onErrorReturn { emptyList() } .doOnNext { migrateMangaInternal(source, it, prevManga, manga, replace) } + .onErrorReturn { emptyList() } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnUnsubscribe { state = state.copy(isReplacingManga = false) } @@ -98,7 +100,11 @@ class MigrationPresenter( db.inTransaction { // Update chapters read if (preferences.migrateChapters().getOrDefault()) { - syncChaptersWithSource(db, sourceChapters, manga, source) + try { + syncChaptersWithSource(db, sourceChapters, manga, source) + } catch (e: Exception) { + // Worst case, chapters won't be synced + } val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking() val maxChapterRead = prevMangaChapters.filter { it.read }