From 7498682b3ce01c0626bbafc2debbca58f988e10b Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Fri, 12 Dec 2025 19:57:01 +0000 Subject: [PATCH] Added additional logging for Android rename/move --- .../java/org/citra/citra_emu/NativeLibrary.kt | 6 ++++++ .../citra/citra_emu/utils/DocumentsTree.kt | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt index 5bf5611c9..5bf6c953b 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/NativeLibrary.kt @@ -683,6 +683,9 @@ object NativeLibrary { try { CitraApplication.documentsTree.renameFile(path, destinationFilename) } catch (e: Exception) { + if (e.message != null) { + Log.error(e.message!!) + } false } } else { @@ -696,6 +699,9 @@ object NativeLibrary { try { CitraApplication.documentsTree.moveFile(filename, sourceDirPath, destinationDirPath) } catch (e: Exception) { + if (e.message != null) { + Log.error(e.message!!) + } false } } else { diff --git a/src/android/app/src/main/java/org/citra/citra_emu/utils/DocumentsTree.kt b/src/android/app/src/main/java/org/citra/citra_emu/utils/DocumentsTree.kt index debdcff03..b1c966f3e 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/utils/DocumentsTree.kt +++ b/src/android/app/src/main/java/org/citra/citra_emu/utils/DocumentsTree.kt @@ -192,7 +192,9 @@ class DocumentsTree { @Synchronized fun renameFile(filepath: String, destinationFilename: String): Boolean { - val node = resolvePath(filepath) ?: return false + val node = resolvePath(filepath) ?: run { + error("[DocumentsTree]: Failed to resolve path during rename: $filepath") + } try { val filename = URLDecoder.decode(destinationFilename, FileUtil.DECODE_METHOD) val newUri = DocumentsContract.renameDocument(context.contentResolver, node.uri!!, filename) @@ -205,9 +207,16 @@ class DocumentsTree { @Synchronized fun moveFile(filename: String, sourceDirPath: String, destDirPath: String): Boolean { - val sourceFileNode = resolvePath(sourceDirPath + "/" + filename) ?: return false - val sourceDirNode = resolvePath(sourceDirPath) ?: return false - val destDirNode = resolvePath(destDirPath) ?: return false + val resolutionErrorMessage = "[DocumentsTree]: Failed to resolve path during move: " + val sourceFileNode = resolvePath(sourceDirPath + "/" + filename) ?: run { + error(resolutionErrorMessage + (sourceDirPath + "/" + filename)) + } + val sourceDirNode = resolvePath(sourceDirPath) ?: run { + error(resolutionErrorMessage + sourceDirPath) + } + val destDirNode = resolvePath(destDirPath) ?: run { + error(resolutionErrorMessage + destDirPath) + } try { val newUri = DocumentsContract.moveDocument(context.contentResolver, sourceFileNode.uri!!, sourceDirNode.uri!!, destDirNode.uri!!) sourceFileNode.rename(filename, newUri) @@ -229,7 +238,7 @@ class DocumentsTree { } return true } catch (e: Exception) { - error("[DocumentsTree]: Cannot rename file, error: " + e.message) + error("[DocumentsTree]: Cannot delete file, error: " + e.message) } }