[TIMOB-23459] Android: Ti.Filesystem.getFile causes hard crash with null argument
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-06-22T08:35:25.000+0000 |
| Affected Version/s | Release 5.4.0 |
| Fix Version/s | Release 6.0.0 |
| Components | Android |
| Labels | n/a |
| Reporter | Christopher Williams |
| Assignee | Hieu Pham |
| Created | 2016-05-31T18:00:42.000+0000 |
| Updated | 2016-08-19T21:20:57.000+0000 |
Description
In our mocha tests suite we used Ti.Filesystem.applicationDirectory to access files from the app Resources directory (xml files, js files, etc). Apparently this property is undefined/null on Android and we should instead be using Ti.Filesystem.resourcesDirectory.
However, if we do something like:
Ti.Filesystem.getFile(Ti.Filesystem.applicationDirectory, 'app.js');
That code will hard-crash Android with an NPE. Considering that is valid code on iOS, and that we don't complain/spit out an error - but actually crash the app, I'd think we might want to safeguard a little better here. If we see a null in the path arguments, we should probably spit out an error and return null.
master PR: https://github.com/appcelerator/titanium_mobile/pull/8038
PR merged. Will require another PR to add log warnings.
PR for master: https://github.com/appcelerator/titanium_mobile/pull/8079
PR Merged.
Verified the fix.
Ti.Filesystem.getFiledoes not cause a hard crash. Closing. Environment: Appc Studio : 4.7.1.201608190732 Ti SDK : 6.0.0.v20160819105028 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-26 Node: 4.4.4 Nexus 6 - Android 6.0.1