[TIMOB-19157] Windows: Ti.Filesystem.File.read() fails on device only if file has .js extension
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-07-06T17:40:45.000+0000 |
Affected Version/s | Release 4.1.0 |
Fix Version/s | Release 4.1.0 |
Components | Windows |
Labels | n/a |
Reporter | Fokke Zandbergen |
Assignee | Christopher Williams |
Created | 2015-07-03T13:20:05.000+0000 |
Updated | 2015-07-06T20:24:13.000+0000 |
Description
The following example works in the emulator but fails on the
.js
file on device:
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
title: 'Click'
});
btn.addEventListener('click', function (e) {
try {
var txt = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'file.txt');
txt.write('Hello world');
txt.read();
} catch (e) {
alert('TXT failed: ' + JSON.stringify(e));
}
try {
var js = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'file.js');
js.write('Hello world');
js.read();
} catch (e) {
alert('JS failed: ' + JSON.stringify(e));
}
alert('all OK');
});
win.add(btn);
win.open();
Error
{
"message": "Could not load module: module_path = C:\\Data\\Users\\DefApps\\APPDATA\\Local\\Packages\com.appc.test_339c21w222ff8\\LocalState\\file.js",
"native_stack": ["JSExportClass<class Titanium::Filesystem::FIle>::CallNamedFunction"],
"stack": "read@[native code]\n",
"line": 1
}
It looks like the .js
extension triggers it (but only on device) to use [readRequiredModule](https://github.com/appcelerator/titanium_mobile_windows/blob/master/Source/Global/src/GlobalObject.cpp#L172-L179) and then fails. It's the only place where I could find this error.
In addition the attached screenshots also show another bug, where a caught exception in an event listener still causes another exception raised?
Attachments
File | Date | Size |
---|---|---|
IMG_6424.JPG | 2015-07-03T13:15:10.000+0000 | 2356639 |
IMG_6425.JPG | 2015-07-03T13:15:32.000+0000 | 4132006 |
May be related to TIMOB-19152
Yes, this was fixed with TIMOB-19152
Verified the fix. Ti.Filesystem.File.read() does not fail. Closing. Environment: Appc Studio: 4.1.0.201507031129 Ti SDK: 4.1.0.v20150706111546 Ti CLI: 4.0.1 Alloy: 1.6.2 Windows: 8.1 Enterprise 64-bit APPC NPM: 4.1.0-1 APPC CLI: 4.1.0-5 Device: Nokia Lumia 928 - Windows Phone 8.1