From 7e7692c3cfa50bf7b6af133be66aefd2b439e251 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:19:45 +0800 Subject: [PATCH] Fix error when updating manga details with uninitialized title (#8045) (cherry picked from commit 2ced56e490ecd175b9575eda6514a933f2893a72) # Conflicts: # app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt --- .../domain/manga/interactor/UpdateManga.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt index a0fe3e0aa..ebc19b41a 100644 --- a/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt +++ b/app/src/main/java/eu/kanade/domain/manga/interactor/UpdateManga.kt @@ -34,10 +34,16 @@ class UpdateManga( downloadManager: DownloadManager = Injekt.get(), // SY <-- ): Boolean { - // SY --> - val title = if (remoteManga.title.isNotBlank() && localManga.ogTitle != remoteManga.title) { - downloadManager.renameMangaDir(localManga.ogTitle, remoteManga.title, localManga.source) + val remoteTitle = try { remoteManga.title + } catch (_: UninitializedPropertyAccessException) { + "" + } + + // SY --> + val title = if (remoteTitle.isNotBlank() && localManga.ogTitle != remoteTitle) { + downloadManager.renameMangaDir(localManga.ogTitle, remoteTitle, localManga.source) + remoteTitle } else { null } @@ -59,16 +65,18 @@ class UpdateManga( } } + val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() } + return mangaRepository.update( MangaUpdate( id = localManga.id, - title = title?.takeIf { it.isNotEmpty() }, + title = title, coverLastModified = coverLastModified, author = remoteManga.author, artist = remoteManga.artist, description = remoteManga.description, genre = remoteManga.getGenres(), - thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() }, + thumbnailUrl = thumbnailUrl, status = remoteManga.status.toLong(), initialized = true, ),