[TIMOB-28177] Android: createTempFile() should create file under Ti.Filesystem.tempDirectory
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Low |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2020-11-20T15:14:52.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 9.3.0 |
| Components | Android |
| Labels | android, filesystem, parity, tempdirectory |
| Reporter | Joshua Quick |
| Assignee | Joshua Quick |
| Created | 2020-10-07T19:50:44.000+0000 |
| Updated | 2020-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 In the log, notice
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.
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