ThinDownloadManager
ThinDownloadManager copied to clipboard
java.io.IOException: open failed: ENOENT (No such file or directory)
I get an error when the library tries to create new file at DownloadDispatcher.java:
destinationFile.createNewFile();
java.io.IOException: open failed: ENOENT (No such file or directory)
03-18 01:06:26.819 15157-15177/kndl.mp3 W/System.err: at java.io.File.createNewFile(File.java:939)
03-18 01:06:26.819 15157-15177/kndl.mp3 W/System.err: at com.thin.downloadmanager.DownloadDispatcher.transferData(DownloadDispatcher.java:213)
03-18 01:06:26.821 15157-15177/kndl.mp3 W/System.err: at com.thin.downloadmanager.DownloadDispatcher.executeDownload(DownloadDispatcher.java:142)
03-18 01:06:26.821 15157-15177/kndl.p3 W/System.err: at com.thin.downloadmanager.DownloadDispatcher.run(DownloadDispatcher.java:81)
03-18 01:06:26.821 15157-15177/kndl.mp3 W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
03-18 01:06:26.821 15157-15157/kndl.mp3 V/ViewRootImpl: Contents drawing finished : kndl.mp3/kndl.mp3.Activities.MainActivity
03-18 01:06:26.822 15157-15177/kndl.mp3 W/System.err: at libcore.io.Posix.open(Native Method)
03-18 01:06:26.822 15157-15177/kndl.mp3 W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
03-18 01:06:26.822 15157-15177/kndl.mp3 W/System.err: at java.io.File.createNewFile(File.java:932)
03-18 01:06:26.822 15157-15177/kndl.mp3 W/System.err: ... 3 more
I think you should check if dir existing, and if it doesn't, than create it using mkdirs:
if (!dir.exists()) {
Log.i(TAG, "directory " + directoryPath + " doesn´t exists!");
if (dir.mkdirs()) { // you will create the directory
Log.i(TAG, "directory succesfully created!");
}
}
I haven't tested it but i think that should solve the issue.
If you update to the latest version 1.2.4
. If the destination directory is not existing, it will throw DownloadManager.ERROR_FILE_ERROR
in the failure callback. I should get two inputs for downloadrequest if this issue needs to be solved. 1) Destination Directory 2) Destination file name. So that i can create the directory if it doesn't exists and create the file under the directory. For now, please check for the file error code in the callback.
how to solve Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) problem please help me its very urgent please.