TeamAmaze / AmazeFileManager

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

NPE on `HybridFile#isDirectory` #3455

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

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

Issue explanation (write below this line)

Hope this helps & is in the correct place

Exception


java.lang.RuntimeException: An error occurred while executing doInBackground()
 at android.os.AsyncTask$4.done(AsyncTask.java:415)
 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 android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
 at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.documentfile.provider.DocumentFile.isDirectory()' on a null object reference
 at com.amaze.filemanager.filesystem.HybridFile.isDirectory(HybridFile.java:579)
 at com.amaze.filemanager.filesystem.files.FileUtils.getBaseFileSize(FileUtils.java:206)
 at com.amaze.filemanager.filesystem.files.FileUtils.getTotalBytes(FileUtils.java:200)
 at com.amaze.filemanager.asynchronous.services.CopyService$DoInBackground.doInBackground(CopyService.java:251)
 at com.amaze.filemanager.asynchronous.services.CopyService$DoInBackground.doInBackground(CopyService.java:234)
 at android.os.AsyncTask$3.call(AsyncTask.java:394)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 ... 4 more


Reporter: via80hd

pR0Ps commented 8 months ago

I can reliably reproduce this by attempting to copy a file from one application's data directory directly into a different application's data directory.

To reproduce:

  1. Give AmazeFileManager permission to access both /storage/emulated/0/Android/com.dev.app1/ and /storage/emulated/0/Android/com.dev.app2/
  2. Attempt to copy /storage/emulated/0/Android/com.dev.app1/some_file directly into /storage/emulated/0/Android/com.dev.app2/.

Note that copying the file to some other non-app directory first, then copying from there to the app2 directory works fine. It seems like just app directory -> app directory is the issue.

VishnuSanal commented 8 months ago

@TranceLove will this be fixed with #4047?

TranceLove commented 8 months ago

@VishnuSanal We may add a band-it solution to fix the NPE, but on the other hand I expect more refactorings to OTGUtils to support multiple URI roots in order for copying between different Android/data directories to work 🥲