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)