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

Error peewee.OperationalError: database is locked on Flatpak profile #18

Open
hedgieinsocks opened this issue Jul 3, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@hedgieinsocks
Copy link

hedgieinsocks commented Jul 3, 2024

Hi! I get peewee.OperationalError: database is locked error if I try to access the database when my Firefox Flatpak is running. I use the following to connect to the database fb.connect(look_under_path='/home/johndoe/.var/app/org.mozilla.firefox/.mozilla/firefox/johndoe.default-release'). I don't think it's related to Flatpak, perhaps I'm missing something?

@BURG3R5 BURG3R5 self-assigned this Jul 3, 2024
@BURG3R5 BURG3R5 added the bug Something isn't working label Jul 3, 2024
@BURG3R5
Copy link
Owner

BURG3R5 commented Jul 3, 2024

Sorry to hear that. This has never occurred during testing, so I need some additional info to find the exact issue.

  1. Is it possible that you're using an extension/script that continuously monitors the bookmarks/places DB?

  2. Does the following code work?

from firefox_bookmarks.connect import *

database = connect_to_places_db(criterion=ProfileCriterion.LARGEST)

@hedgieinsocks
Copy link
Author

Thank you for your prompt reply!

I must provide the full path where the Flatpak version is installed, cause it looks only in the default path

return os.path.expanduser("~/.mozilla/firefox")

Unfortunately, with all the plugins disabled, the error persists.

But I've managed to interact with the database via cli by setting the immutable flag.

❯ sqlite3 'file:/home/USER/.var/app/org.mozilla.firefox/.mozilla/firefox/PROFILE.default-release/places.sqlite?immutable=1'

Perhaps it's possible to pass that flag here? If not, I'm already grateful for learning the search sql query from your examples.

@BURG3R5
Copy link
Owner

BURG3R5 commented Jul 4, 2024

I think I can add a fallback to access the DB via file URI with the immutable flag. But just to confirm where the problem is, can you try the following code?

from firefox_bookmarks.connect import *

database = connect_to_places_db(look_under_path='/home/johndoe/.var/app/org.mozilla.firefox/.mozilla/firefox/johndoe.default-release')  # substituting your username, of course

I want to be sure that the issue is with the connect_to_places_db method, not with the _load or some other method.

@hedgieinsocks
Copy link
Author

Yeah, with the suggested code it is the same. And I guess it is expected because vanilla cli sqlite3 results in the same database lock message at the first sql command. I can see that people workaround it by making a tmp copy of a database.

@BURG3R5
Copy link
Owner

BURG3R5 commented Jul 4, 2024

Alright, I've reviewed the bug and decided on the following approach:

  1. To ensure that users aren't surprised by their scripts silently using a temporary duplicate DB (that, at least for the time being, won't be synced with the original places.db), I'll have the connect method raise an Exception if the DB is locked.

  2. The Exception's message will direct users to a different connect_read_only method, which will utilize a temporary duplicate.

@hedgieinsocks
Copy link
Author

Sure, sounds nice. Since it works for you, but some people face my error, I guess it might be that some firefox packages are just compiled to use exclusive lock on db. Or maybe the underlying libraries play their role

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants