Fix download error with empty largeCoverUrl

feature/kitsu v5.0.2
Koitharu 3 years ago
parent 5fc08d9ecb
commit 12e9fb5aab
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -41,6 +41,7 @@ import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.parsers.util.await import org.koitharu.kotatsu.parsers.util.await
import org.koitharu.kotatsu.utils.ext.copyToSuspending import org.koitharu.kotatsu.utils.ext.copyToSuspending
import org.koitharu.kotatsu.utils.ext.deleteAwait import org.koitharu.kotatsu.utils.ext.deleteAwait
import org.koitharu.kotatsu.utils.ext.ifNullOrEmpty
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
import org.koitharu.kotatsu.utils.ext.runCatchingCancellable import org.koitharu.kotatsu.utils.ext.runCatchingCancellable
import org.koitharu.kotatsu.utils.progress.PausingProgressJob import org.koitharu.kotatsu.utils.progress.PausingProgressJob
@ -124,9 +125,11 @@ class DownloadManager @Inject constructor(
outState.value = DownloadState.Preparing(startId, manga, cover) outState.value = DownloadState.Preparing(startId, manga, cover)
val data = if (manga.chapters.isNullOrEmpty()) repo.getDetails(manga) else manga val data = if (manga.chapters.isNullOrEmpty()) repo.getDetails(manga) else manga
output = LocalMangaOutput.getOrCreate(destination, data) output = LocalMangaOutput.getOrCreate(destination, data)
val coverUrl = data.largeCoverUrl ?: data.coverUrl val coverUrl = data.largeCoverUrl.ifNullOrEmpty { data.coverUrl }
downloadFile(coverUrl, destination, tempFileName, repo.source).let { file -> if (coverUrl.isNotEmpty()) {
output.addCover(file, MimeTypeMap.getFileExtensionFromUrl(coverUrl)) downloadFile(coverUrl, destination, tempFileName, repo.source).let { file ->
output.addCover(file, MimeTypeMap.getFileExtensionFromUrl(coverUrl))
}
} }
val chapters = checkNotNull( val chapters = checkNotNull(
if (chaptersIdsSet == null) { if (chaptersIdsSet == null) {

Loading…
Cancel
Save