[AC-794] Ti Database install failure when absolute path containing spaces is passed
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Cannot Reproduce |
Resolution Date | 2015-09-29T01:59:11.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | filesystem, ios |
Reporter | Hani Hamadeh |
Assignee | Shak Hossain |
Created | 2015-02-18T17:24:36.000+0000 |
Updated | 2016-03-08T07:37:04.000+0000 |
Description
When a db file is shipped in resources and installed by providing its absolute path, the install function fails to find the file if the path contains spaces (i.e. the app name contains spaces)
This was introduced in commit https://github.com/appcelerator/titanium_mobile/commit/d0db5dab7ba6e91642bedbc4fec946e38d23b5b3 which replaced the absoluteString with path in Ti.FileSystem.ResourcesDirectory
As a result, the string passed to the install function contains unescaped spaces which affect the logic of the function. (in Ti 3.4.1 and earlier the path passed to the install function contains %20)
To reproduce: Create a new classic project containing a space in the project name and put a file in resources named mydb.db then try running the following code with Ti 3.5 or newer
Titanium.Database.install(Titanium.Filesystem.resourcesDirectory+'mydb.db','db');
You should get something like the following error:
{noformat}
[ERROR] : Script Error {
[ERROR] : column = 26;
[ERROR] : line = 1;
[ERROR] : message = "Could not retrieve attributes";
[ERROR] : nativeLocation = "-[TiDatabaseProxy install:name:] (TiDatabaseProxy.m:131)";
[ERROR] : nativeReason = "Error Domain=NSCocoaErrorDomain Code=260 \"The operation couldn\U2019t be completed. (Cocoa error 260.)\" UserInfo=0x7fdf1944d290 {NSFilePath=/Users/userx/Library/Developer/CoreSimulator/Devices/ABE968BE-F288-48F7-B714-A065B48472B8/data/Containers/Bundle/Application/3A077915-566E-4B26-8237-72D551068655/db Test.app/Users/userx/Library/Developer/CoreSimulator/Devices/ABE968BE-F288-48F7-B714-A065B48472B8/data/Containers/Bundle/Application/3A077915-566E-4B26-8237-72D551068655/db Test.app/mydb.db, NSUnderlyingError=0x7fdf1944d5f0 \"The operation couldn\U2019t be completed. No such file or directory\"}";
[ERROR] : sourceURL = "file:///Users/userx/Library/Developer/CoreSimulator/Devices/ABE968BE-F288-48F7-B714-A065B48472B8/data/Containers/Bundle/Application/3A077915-566E-4B26-8237-72D551068655/db%20Test.app/app.js";
[ERROR] : stack = "[native code]\nglobal code@file:///Users/userx/Library/Developer/CoreSimulator/Devices/ABE968BE-F288-48F7-B714-A065B48472B8/data/Containers/Bundle/Application/3A077915-566E-4B26-8237-72D551068655/db%20Test.app/app.js:1:26";
[ERROR] : }
{noformat}
Hello, I tested the issue you reported. We did not reproduce this issue as a bug. It works as expected. So I recommend you upgrade studio and SDK to the latest build and use ".sqlite" extension initiate of ".db" then let us know if you get the error again.
Thanks