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
*/
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

View File

@ -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)) {

View File

@ -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<SChapter>,
prevManga: Manga,