TeamAmaze / AmazeFileManager

Material design file manager for Android
https://teamamaze.xyz
GNU General Public License v3.0
5.37k stars 1.58k forks source link

ShellCommandInvalidException on move #2238

Open amaze-issue-automation[bot] opened 3 years ago

amaze-issue-automation[bot] commented 3 years ago

Issue explanation (write below this line)

Exception

java.lang.RuntimeException: An error occurred while executing
doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:365)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:784)
Caused by: com.amaze.filemanager.exceptions.ShellCommandInvalidException:
mv "/storage/emulated/0/Pictures/EsBP2UvXAAUzpdy.png"
"/storage/9C33-6BBD/NMEL/EsBP2UvXAAUzpdy.png" , error code - 1
at
com.amaze.filemanager.filesystem.root.base.IRootCommand.runShellCommandToList(IRootCommand.kt:54)
at
com.amaze.filemanager.filesystem.root.RenameFileCommand.renameFile(RenameFileCommand.kt:41)
at
com.amaze.filemanager.asynchronous.asynctasks.MoveFiles.doInBackground(MoveFiles.java:114)
at
com.amaze.filemanager.asynchronous.asynctasks.MoveFiles.doInBackground(MoveFiles.java:59)
at android.os.AsyncTask$2.call(AsyncTask.java:345)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
... 3 more


EmmanuelMess commented 3 years ago

Update: Now crash is on runShellCommandToList(IRootCommand.kt:54)

TranceLove commented 3 years ago

I could reproduce this only when the Android Shell process is denied superuser permission.

VishalNehra commented 3 years ago

@TranceLove What about denied sd card write permission? I think someone reported the couldn't copy files to sd card and got this crash. Is it possible that if sd card permission is not there we actually fallback to root method?

TranceLove commented 3 years ago

@VishalNehra From what I read, when File.renameTo() failed root mode is used right away if root is enabled. Otherwise MoveFiles would fail, and resort to CopyService + delete source at MoveFiles.onPostExecute()

https://github.com/TeamAmaze/AmazeFileManager/blob/bed5d1313ec57aac9acb66575b1cb6405867a018/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/MoveFiles.java#L106-L122

DrAzraelTod commented 3 years ago

Happened when copying specific (not all) files to SD from internal downloads.

Worked again and again on affected files - others had no issues ever.

Amaze had root