Titanium JIRA Archive
Appcelerator Community (AC)

[AC-794] Ti Database install failure when absolute path containing spaces is passed

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-09-29T01:59:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsfilesystem, ios
ReporterHani Hamadeh
AssigneeShak Hossain
Created2015-02-18T17:24:36.000+0000
Updated2016-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}

Comments

  1. Motiur Rahman 2015-08-25

    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.
       var db = Titanium.Database.install(Titanium.Filesystem.resourcesDirectory + 'mydatabase.sqlite', 'mydatabase');
       
    Thanks

JSON Source