Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28177] Android: createTempFile() should create file under Ti.Filesystem.tempDirectory

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-11-20T15:14:52.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsandroid, filesystem, parity, tempdirectory
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-10-07T19:50:44.000+0000
Updated2020-11-20T15:14:52.000+0000

Description

*Summary:* On Android, the [Ti.Filesystem.createTempFile()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Filesystem-method-createTempFile) method creates the file under the root Ti.Filesystem.applicationCacheDirectory when it should be created under the Ti.Filesystem.tempDirectory instead like iOS. *Steps to reproduce:*

Build and run the below code on Android.

In the log, notice nativePath is immediately under the cache folder.

var tempFile = Ti.Filesystem.createTempFile();
console.log('@@@ nativePath: ' + tempFile.nativePath);
console.log('@@@ tempDirectory: ' + Ti.Filesystem.tempDirectory);
console.log('@@@ applicationCacheDirectory: ' + Ti.Filesystem.applicationCacheDirectory);
*Note:* On Android, the tempDirectory is a subfolder under the applicationCacheDirectory. This is okay since Android does not natively support both of these folders. You are expected to put temp files under the app's sandboxed "cache" folder. However, Titanium should keep temp files under a separate temp subfolder so that we can clean it ourselves on app startup and let the Android OS clean the rest of the cached files when needed.

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