From 38b7a7f4d855b36e2ec42b71adf99967db85e111 Mon Sep 17 00:00:00 2001 From: Hinnka Date: Sat, 30 May 2026 18:06:00 +0800 Subject: [PATCH] fix: refine burst photo saving and error handling --- .../hinnka/mycamera/gallery/GalleryManager.kt | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/hinnka/mycamera/gallery/GalleryManager.kt b/app/src/main/java/com/hinnka/mycamera/gallery/GalleryManager.kt index 7a94506e..f681e0b6 100644 --- a/app/src/main/java/com/hinnka/mycamera/gallery/GalleryManager.kt +++ b/app/src/main/java/com/hinnka/mycamera/gallery/GalleryManager.kt @@ -2055,26 +2055,38 @@ object GalleryManager { val noiseReductionValue = metadata.noiseReduction ?: 0f val chromaNoiseReductionValue = metadata.chromaNoiseReduction ?: 0f - image.use { + val saved = image.use { YuvProcessor.processAndSave( image, metadata.rotation, photoFile.absolutePath ) } + if (!saved || !photoFile.exists()) { + PLog.e(TAG, "YuvProcessor failed to process and save burst photo for $photoId") + return + } if (!mainPhotoFile.exists() || mainPhotoFile.length() == 0L) { processingScope.launch { - photoFile.copyTo(mainPhotoFile, overwrite = true) - if (shouldAutoSave) { - exportPhoto( - context, - photoId, - null, - photoProcessor, - metadata, - sharpeningValue, - noiseReductionValue, - chromaNoiseReductionValue, - photoQuality - ) + try { + if (photoFile.exists()) { + photoFile.copyTo(mainPhotoFile, overwrite = true) + if (shouldAutoSave) { + exportPhoto( + context, + photoId, + null, + photoProcessor, + metadata, + sharpeningValue, + noiseReductionValue, + chromaNoiseReductionValue, + photoQuality + ) + } + } else { + PLog.e(TAG, "Burst photo file does not exist during copy: ${photoFile.absolutePath}") + } + } catch (e: Exception) { + PLog.e(TAG, "Failed to copy burst photo asynchronously", e) } } }