diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index fc5565de9..7cbaf3ed0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -233,10 +233,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View val currPath = getCurrentPath() SaveAsDialog(this, currPath) { try { - val file = File(it) + val selectedFile = File(it) + val tmpFile = File(selectedFile.parent, "tmp_${it.getFilenameFromPath()}") val bitmap = BitmapFactory.decodeFile(currPath) - getFileOutputStream(file) { - saveFile(file, bitmap, it) + getFileOutputStream(tmpFile) { + saveFile(tmpFile, bitmap, it) + renameFile(tmpFile, selectedFile) { } } } catch (e: OutOfMemoryError) { toast(R.string.out_of_memory_error)