From 346652e508b0aea1f1a9bdc97f4e4c6f1fcb0789 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 8 Apr 2022 15:55:12 -0400 Subject: [PATCH] Ensure media store scan is triggered after saving an image (fixes #6808) --- .../main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt | 6 +++++- .../java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt index 4b55ccb1f7..3324efcd48 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/saver/ImageSaver.kt @@ -24,7 +24,7 @@ class ImageSaver( ) { @SuppressLint("InlinedApi") - suspend fun save(image: Image): Uri { + fun save(image: Image): Uri { val data = image.data val type = ImageUtil.findImageType(data) ?: throw Exception("Not an image") @@ -63,6 +63,8 @@ class ImageSaver( } } + DiskUtil.scanMedia(context, picture) + return picture } @@ -77,6 +79,8 @@ class ImageSaver( } } + DiskUtil.scanMedia(context, destFile) + return destFile.getUriCompat(context) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 5fd1b6fefa..c4fd7c1eb2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -343,7 +343,7 @@ class MangaPresenter( * @param image the image with specified location * @return flow Flow which emits the Uri which specifies where the image is saved when */ - suspend fun saveImage(image: Image): Uri { + fun saveImage(image: Image): Uri { return imageSaver.save(image) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 2c633406d0..454d0148a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -597,7 +597,6 @@ class ReaderPresenter( val relativePath = if (preferences.folderPerManga()) DiskUtil.buildValidFilename(manga.title) else "" // Copy file in background. - try { presenterScope.launchIO { val uri = imageSaver.save( @@ -608,7 +607,6 @@ class ReaderPresenter( ) ) launchUI { - DiskUtil.scanMedia(context, uri) notifier.onComplete(uri) view!!.onSaveImageResult(SaveImageResult.Success(uri)) }