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

use SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE to retry when SQLITE_OPEN_READWRITE fails on native platforms. #51

Merged
merged 9 commits into from
Oct 18, 2023

Conversation

nbransby
Copy link
Contributor

No description provided.

@qiaoyuang
Copy link
Collaborator

Hi, I have seen your commits. But, after your modification, if a user set isReadOnly = true, he will get a writable database on Android, and a read-only database on the native platform. If it has the big difference on different platforms, I don't think that is a good idea.

And, I don't understand if I set isReadOnly = false, why the code would try to open the database twice with the same flags(sqliteCreateFlags).

@nbransby
Copy link
Contributor Author

Good points, what about now? Sorry I am doing all these edits in the GitHub web editor - you'll definitely want to squash when merging!

@qiaoyuang
Copy link
Collaborator

Yeah, It's OK. Let's run a round workflow.

@qiaoyuang qiaoyuang merged commit 1d12b5c into ctripcorp:main Oct 18, 2023
3 checks passed
@nbransby
Copy link
Contributor Author

@qiaoyuang are you able to create a new release today? We need the fix asap, otherwise we'll try and publish one internally

@qiaoyuang
Copy link
Collaborator

Yes, I am planning to do this. Do you mind me updating the Kotlin version to 1.9.10 in this release version?

@nbransby
Copy link
Contributor Author

nbransby commented Oct 18, 2023 via email

@qiaoyuang
Copy link
Collaborator

Hi, @nbransby. I submitted a PR for this new release. I commented out these code in NativeDatabase:

if ((sqliteFlags and SQLITE_OPEN_READWRITE > 0) && sqlite3_db_readonly(db, null) != 0) {
       sqlite3_close_v2(db)
       throw sqliteException("Could not open the database in read/write mode")
}

Because, I think we should return a read-only database object to users when OS ban the writing permission or the situation of full disk. So, we don't check whether the database is writable anymore. You can review my code in there. And, I also fix the format of code.

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

Successfully merging this pull request may close these issues.

None yet

2 participants