Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28176] Android: createTempDirectory() does not create a directory

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-11-20T14:37:31.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, directory, filesystem, parity
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-10-07T19:38:22.000+0000
Updated2020-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 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());

Comments

  1. Joshua Quick 2020-10-07

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12161
  2. Satyam Sekhri 2020-10-19

    FR Passed. Waiting for Jenkins build.
  3. Christopher Williams 2020-10-19

    Merged to master for 9.3.0 target
  4. Samir Mohammed 2020-11-20

    *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

JSON Source