Project: titanium
Issue TIMOB-20470: Android 6.0 (Post 5.2.0 SDK): java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
h3. Steps to Reproduce I played around with the latest 5.2.0 SDK and Nexus 6P... for the most part everything seems to work except for one case with runtime permission. if I use Ti.Filesystem.tempDirectory as my storage and created the permission checks, this still fails on first try even if you accept the Permission. Log: [INFO] : Permission granted? true [ERROR] : TiFileProxy: (KrollRuntimeThread) [66154,66154] IOException encountered [ERROR] : TiFileProxy: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.apptest.tempdirperm/cache/_tmp/GettingStartedTitanium_Linux.pdf: open failed: ENOENT (No such file or directory) [ERROR] : TiFileProxy: at libcore.io.IoBridge.open(IoBridge.java:452) [ERROR] : TiFileProxy: at java.io.FileOutputStream.(FileOutputStream.java:87) [ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.getOutputStream(TiFile.java:273) [ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.open(TiFile.java:336) [ERROR] : TiFileProxy: at org.appcelerator.titanium.io.TiFile.write(TiFile.java:382) [ERROR] : TiFileProxy: at org.appcelerator.titanium.TiFileProxy.write(TiFileProxy.java:290) [ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method) [ERROR] : TiFileProxy: at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73) [ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155) [ERROR] : TiFileProxy: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiFileProxy: at android.os.Looper.loop(Looper.java:148) [ERROR] : TiFileProxy: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118) [ERROR] : TiFileProxy: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) [ERROR] : TiFileProxy: at libcore.io.Posix.open(Native Method) [ERROR] : TiFileProxy: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) [ERROR] : TiFileProxy: at libcore.io.IoBridge.open(IoBridge.java:438) [ERROR] : TiFileProxy: ... 11 more [INFO] : ALERT: (KrollRuntimeThread) [41,66195] File exist? false}} Steps to recreate: Create new Mobile App Project and paste in code to index.js Compile and run, make sure it is a clean install on device Click the 'Hello, World' to trigger the download and permission. Accept the permission on popup. Accessing the file in temporary directory fails. (alert will say file does not exist) Close the app Check permission in settings > app permission (storage should be enabled) Restart the app Click 'Hello, World' again to trigger download. Alert will now say file exists. Workaround: If I switch the Ti.Filesystem.tempDirectory to Ti.Filesystem.applicationDataDirectory, I do not run into the issue of having to restart the app to open the file. But I have to make sure those files are deleted after use. It would be best to use temporary directory so that the files are automatically removed after app is closed. h3. Actual Result File does not exist in tempDirectory when permission is enabled on RunTime. h3. Expected Result File should exist in tempDirectory.
Story points: 3