Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support to enabling database when ios is locked #264

Closed
wants to merge 4 commits into from

Conversation

vzaidman
Copy link

if root.sqlitePlugin.enableDatabaseWhenLocked is not setted, plugin is using the default security.
if setted to true ios would permit an open before lock database to be used.
if setted to false ios would forbid any use of the file when it is locked.

vzaidman added 3 commits May 13, 2015 09:25
Enabling database when locked now disables database file security whatsoever so it can always be open.
@brodycj
Copy link
Contributor

brodycj commented Jun 21, 2015

Thanks for the contribution and my apologies for the delay. Can you elaborate about when you would expect the sqlite database file to be locked inadvertently, i.e. "application forgets to close the database", "application crashes", etc. and also what the sqlite document says about the file locking?

If this is a common-place problem, I would consider enabling this fix by default. If this problem is caused by programmer error, I would prefer to document this problem very clearly, along with a possible workaround such as using the File API.

@vzaidman
Copy link
Author

Ok, I'll explain briefly as I do not have the resources for a full research:

I encountered a problem when tried to write to the plugin's DB in a locked with a password iPad when in Background Fetch.

Looks like ios locks the file system when the device is locked and unless NSFileProtectionNone is set for a file (database file in our case) it cannot be accessed when the phone is locked. (code 0: "unable to open database file").

There are several possible values for the key NSFileProtectionKey of a file. None of them, but the specified above, let me write to the DB when iPad was locked.

The problem with this solution though, is that we might want to protect the database of our cordova application, and I believe NSFileProtectionNone shouldn't be the default value unless the user specifies he wants to give up on his database protection.

EDIT: Now, it looks like the whole documents directory should be set to NSFileProtectionNone

added logging of successful disabling of file protection of database.
now disables file protection after database opening so it would apply on first launch as well.
@brodycj
Copy link
Contributor

brodycj commented May 11, 2018

Closing in favor of #786, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants