[TIMOB-28176] Android: createTempDirectory() does not create a directory
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-20T14:37:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | android, directory, filesystem, parity |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-10-07T19:38:22.000+0000 |
Updated | 2020-11-20T14:37:31.000+0000 |
Description
*Summary:*
The [Ti.Filesystem.createTempDirectory()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-createTempDirectory) method does not create the referenced directory by default on Android. It correctly returns a Notice in the log that "exists" returns
Ti.Filesystem.File
object referencing a new directory, but the Titanium developer is forced to create it manually afterwards, which doesn't match iOS' behavior or what's implied by the method name.
*Steps to reproduce:*
Build and run the below on Android.
Notice in the log that "exists" returns false
. _(This is the bug.)_
var tempDir = Ti.Filesystem.createTempDirectory();
console.log("@@@ nativePath: " + tempDir.nativePath);
console.log("@@@ exists: " + tempDir.exists());
*Note:*
Android should also be changed to create the temp directory under the Ti.Filesystem.tempDirectory
like iOS. Currently, Android puts the temp directory in a radically different location that Titanium does not offer a directory constant for.
*Work-Around:*
You must create the directory manually like the below.
var tempDir = Ti.Filesystem.createTempDirectory();
if (OS_ANDROID) {
tempDir.createDirectory();
}
console.log("@@@ exists: " + tempDir.exists());
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12161
FR Passed. Waiting for Jenkins build.
Merged to master for 9.3.0 target
*Closing ticket*. Fix verified in SDK version
9.3.0.v20201119063936
. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/12161