From 89dbb4d300b7a5dc6f1dcb01d6366f731f730217 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 23 Jan 2022 17:21:23 -0500 Subject: [PATCH] Avoid migration failing if previous source doesn't exist --- .../eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt | 2 +- .../main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt | 4 ++-- .../tachiyomi/ui/browse/migration/search/SearchPresenter.kt | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt index 21ee0e7e42..08060f3dac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/EnhancedTrackService.kt @@ -30,7 +30,7 @@ interface EnhancedTrackService { /** * Checks whether the provided source/track/manga triplet is from this TrackService */ - fun isTrackFrom(track: Track, manga: Manga, source: Source): Boolean + fun isTrackFrom(track: Track, manga: Manga, source: Source?): Boolean /** * Migrates the given track for the manga to the newSource, if possible diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt index 03afcb2134..b9cb86518c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/komga/Komga.kt @@ -105,8 +105,8 @@ class Komga(private val context: Context, id: Int) : TrackService(id), EnhancedT null } - override fun isTrackFrom(track: Track, manga: Manga, source: Source): Boolean = - accept(source) && track.tracking_url == manga.url + override fun isTrackFrom(track: Track, manga: Manga, source: Source?): Boolean = + track.tracking_url == manga.url && source?.let { accept(it) } == true override fun migrateTrack(track: Track, manga: Manga, newSource: Source): Track? = if (accept(newSource)) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt index 82446c59ce..84bc76cf48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/search/SearchPresenter.kt @@ -63,8 +63,8 @@ class SearchPresenter( } fun migrateManga(prevManga: Manga, manga: Manga, replace: Boolean) { - val prevSource = sourceManager.get(prevManga.source) ?: return val source = sourceManager.get(manga.source) ?: return + val prevSource = sourceManager.get(prevManga.source) replacingMangaRelay.call(Pair(true, null)) @@ -83,7 +83,7 @@ class SearchPresenter( } private fun migrateMangaInternal( - prevSource: Source, + prevSource: Source?, source: Source, sourceChapters: List, prevManga: Manga,