anggrayudi / SimpleStorage

💾 Simplify Android Storage Access Framework for file management across API levels.
Apache License 2.0
805 stars 98 forks source link

Rename recovery failed #97

Closed SarmadNazer closed 1 year ago

SarmadNazer commented 2 years ago

Library version: 1.4.1 OS version: [Android 12] Device model: [Pixel 3]

Describe the bug I'm trying to move the public Downloads folder to the app's external storage, and files move but I also facing the stack trace and move folder method and also not calling the callback methods correctly. I also gives all file access permission

To Reproduce ` val file = File("/storage/emulated/0/Downloads") val externalStorage = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) if (externalStorage!!.exists().not()) { externalStorage.mkdirs() } val source = file.toDocumentFile(this) val target = externalStorage.toDocumentFile(this) try { source?.moveFolderTo(this, target!!, callback = object : FolderCallback() { override fun onCheckFreeSpace(freeSpace: Long, fileSize: Long): Boolean { Log.d(TAG, "onCheckFreeSpace: ") return true }

            override fun onCompleted(result: Result) {
                Log.d(TAG, "onCompleted: ${result.totalCopiedFiles}")
            }

            override fun onDeleteConflictedFiles() {
                Log.d(TAG, "onDeleteConflictedFiles: ")
            }

            override fun onFailed(errorCode: ErrorCode) {
                Log.d(TAG, "onFailed: ")

            }

            override fun onPrepare() {
                Log.d(TAG, "onPrepare: ")

            }

            override fun onReport(report: Report) {
                Log.d(TAG, "onReport: ")
            }

            override fun onValidate() {
                Log.d(TAG, "onValidate: ")
            }

            override fun onContentConflict(
                destinationFolder: DocumentFile,
                conflictedFiles: MutableList<FileConflict>,
                action: FolderContentConflictAction
            ) {
                Log.d(TAG, "onContentConflict: ")
            }

            override fun onCountingFiles() {
                Log.d(TAG, "onCountingFiles: ")

            }

            override fun onParentConflict(
                destinationFolder: DocumentFile,
                action: ParentFolderConflictAction,
                canMerge: Boolean
            ) {
                Log.d(TAG, "onParentConflict: ")
            }

            override fun onStart(
                folder: DocumentFile,
                totalFilesToCopy: Int,
                workerThread: Thread
            ): Long {
                Log.d(TAG, "onStart: ")
                return 100L
            }
        })

**Stacktrace** 2022-08-11 11:19:27.729 25710-25710/filemanager.example.fileorganizer E/ActivityThread: Rename recovery failed android.system.ErrnoException: rename failed: EXDEV (Cross-device link) at libcore.io.Linux.rename(Native Method) at libcore.io.ForwardingOs.rename(ForwardingOs.java:698) at libcore.io.BlockGuardOs.rename(BlockGuardOs.java:375) at libcore.io.ForwardingOs.rename(ForwardingOs.java:698) at android.app.ActivityThread$AndroidOs.rename(ActivityThread.java:7767) at java.io.UnixFileSystem.rename(UnixFileSystem.java:368) at java.io.File.renameTo(File.java:1410) at com.anggrayudi.storage.file.FileUtils.moveTo(FileExt.kt:341) at com.anggrayudi.storage.file.FileUtils.moveTo$default(FileExt.kt:311) at filemanager.fileexplorer.fileorganizer.ui.MainActivity.performMoveOpration(MainActivity.kt:71) at filemanager.fileexplorer.fileorganizer.ui.MainActivity.onCreate$lambda-1(MainActivity.kt:56) at filemanager.fileexplorer.fileorganizer.ui.MainActivity.$r8$lambda$Sr_Pb-M_Py7rkIlSWBA_uMeW92M(Unknown Source:0) at filemanager.fileexplorer.fileorganizer.ui.MainActivity$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at android.view.View.performClick(View.java:7441) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1194) at android.view.View.performClickInternal(View.java:7418) at android.view.View.access$3700(View.java:835) at android.view.View$PerformClick.run(View.java:28676) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7842) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) D/MainActivity: onValidate: D/MainActivity: onPrepare: D/MainActivity: onCountingFiles: D/MainActivity: onCompleted: 481 `

anggrayudi commented 2 years ago

Have you requested full disk access from the user? Read Manage all files on a storage device

anggrayudi commented 1 year ago

Closed. Too long inactive.

SarmadNazer commented 1 year ago

Yes, I also give Read Manage all files on a storage device