Avoid migration failing if previous source doesn't exist

This commit is contained in:
arkon 2022-01-23 17:21:23 -05:00
parent e3f3686b8a
commit 89dbb4d300
3 changed files with 5 additions and 5 deletions

View file

@ -30,7 +30,7 @@ interface EnhancedTrackService {
/** /**
* Checks whether the provided source/track/manga triplet is from this TrackService * 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 * Migrates the given track for the manga to the newSource, if possible

View file

@ -105,8 +105,8 @@ class Komga(private val context: Context, id: Int) : TrackService(id), EnhancedT
null null
} }
override fun isTrackFrom(track: Track, manga: Manga, source: Source): Boolean = override fun isTrackFrom(track: Track, manga: Manga, source: Source?): Boolean =
accept(source) && track.tracking_url == manga.url track.tracking_url == manga.url && source?.let { accept(it) } == true
override fun migrateTrack(track: Track, manga: Manga, newSource: Source): Track? = override fun migrateTrack(track: Track, manga: Manga, newSource: Source): Track? =
if (accept(newSource)) { if (accept(newSource)) {

View file

@ -63,8 +63,8 @@ class SearchPresenter(
} }
fun migrateManga(prevManga: Manga, manga: Manga, replace: Boolean) { fun migrateManga(prevManga: Manga, manga: Manga, replace: Boolean) {
val prevSource = sourceManager.get(prevManga.source) ?: return
val source = sourceManager.get(manga.source) ?: return val source = sourceManager.get(manga.source) ?: return
val prevSource = sourceManager.get(prevManga.source)
replacingMangaRelay.call(Pair(true, null)) replacingMangaRelay.call(Pair(true, null))
@ -83,7 +83,7 @@ class SearchPresenter(
} }
private fun migrateMangaInternal( private fun migrateMangaInternal(
prevSource: Source, prevSource: Source?,
source: Source, source: Source,
sourceChapters: List<SChapter>, sourceChapters: List<SChapter>,
prevManga: Manga, prevManga: Manga,