From b406941f5c860a0f93824b7b3082e387cb624f62 Mon Sep 17 00:00:00 2001 From: nonproto <2092019+nonproto@users.noreply.github.com> Date: Thu, 27 Jun 2024 07:41:46 -0400 Subject: [PATCH] Move loading pages directory into try catch --- .../kanade/tachiyomi/ui/reader/ReaderViewModel.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt index 59bcab1c90..8cdcd42a5b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt @@ -857,7 +857,7 @@ class ReaderViewModel( isLTR: Boolean, @ColorInt bg: Int ) { - scope.launch { + viewModelScope.launchNonCancellable { if (firstPage.status != Page.State.READY) return@launch if (secondPage.status != Page.State.READY) return@launch val manga = manga ?: return@launch @@ -866,13 +866,13 @@ class ReaderViewModel( val notifier = SaveImageNotifier(context) notifier.onClear() - var directory = storageManager.getPagesDirectory()!! - - if (preferences.folderPerManga().get()) { - directory = directory.createDirectory(DiskUtil.buildValidFilename(manga.title))!! - } - try { + var directory = storageManager.getPagesDirectory()!! + + if (preferences.folderPerManga().get()) { + directory = + directory.createDirectory(DiskUtil.buildValidFilename(manga.title))!! + } val file = saveImages(firstPage, secondPage, isLTR, bg, directory, manga) DiskUtil.scanMedia(context, file.uri) notifier.onComplete(file)