From 4da6d24e7e48b9f549d261f0bc6b5696d120ed63 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Nicolas <6371790+pynicolas@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:24:52 +0100 Subject: [PATCH] Fix bug with JPEG when clicking twice on Save --- .../org/fairscan/app/ui/screens/export/ExportViewModel.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt b/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt index 8ae7f49..5ca040b 100644 --- a/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt +++ b/app/src/main/java/org/fairscan/app/ui/screens/export/ExportViewModel.kt @@ -142,8 +142,10 @@ class ExportViewModel(container: AppContainer): ViewModel() { val renamedFiles = files.mapIndexed { index, file -> val indexSuffix = if (files.size == 1) "" else "_${index + 1}" val newFile = File(file.parentFile, "${base}${indexSuffix}.jpg") - if (newFile.exists()) newFile.delete() - file.renameTo(newFile) + if (file.absolutePath != newFile.absolutePath) { + if (newFile.exists()) newFile.delete() + file.renameTo(newFile) + } newFile } val updated = result.copy(jpegFiles = renamedFiles)