-
Notifications
You must be signed in to change notification settings - Fork 332
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
obok: linux: improve Kobo Desktop directory searching #44
base: master
Are you sure you want to change the base?
Conversation
The Kobo Desktop program will (when running under Wine on Linux) put all of its data in the current working directory. This means that there may be more than one Kobo.sqlite floating around by the user, which leads to Obok showing an outdated list of books and the user being confused by Obok cannot find the full list of books. Solving this completely appears to be a bit too complicated, so this patch is a best-effort improvement for the worst cases which can be caused by this: 1. If the user deletes the files but Obok has already cached the path, previously Obok would just error out rather than trying to search for a new Kobo.sqlite path and updating the cache. 2. We search $HOME before searching /, which speeds up initial usage of Obok in the common case (usually Kobo Desktop will be installed in ~/.wine/drive_c) and also ensures that we correctly preference the current user's Kobo Desktop installation. Signed-off-by: Aleksa Sarai <[email protected]>
self.kobodir = f.read() | ||
|
||
# desktop versions use Kobo.sqlite | ||
kobodir_cache_file = os.path.join(kobodir_cache_dir, "kobo-location") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this into ~/.config/calibre/plugins/obok
since that better matches the internal calibre configuration paths than just dumping it in ~/.config/calibre
. Users upgrading shouldn't notice a huge difference (thanks to the $HOME
optimisation, the first search will be fairly quick) though in theory (since there might be multiple Kobo.sqlite
files on their machine) this might change which Kobo data directory is used.
# It should also be noted that Kobo Desktop will store all | ||
# of it files in the current directory where you run it, | ||
# meaning that a user might accidentally create several | ||
# Kobo.sqlite files which are all separate and then be | ||
# confused why Obok can't find any of the new books. Sadly | ||
# there isn't a trivial way to deal with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible solution would be to look at the last-touched Kobo.sqlite
file. However this would cause issues with our caching -- even if we stored all paths found in the cache, the user might accidentally create a new one (because they don't notice Kobo Desktop's incredibly strange behaviour). So we wouldn't be able to cache them.
The other option would be to look at whether there is a running wine Kobo.exe
program and then use its /proc/self/cwd
path but that has a whole host of other issues.
I am not familiar with the Kobo Desktop application, but to me, both the old and the new implementation sound like a very bad idea. In the worst case, this will walk through the whole HOME directory, and then again walk through Looking at the Windows code, the Kobo app seems to use a subfolder of At least that's how it's currently done with the main DeDRM plugin (there's a WINEPREFIX input field in the settings for Linux users where they can enter the path to their Wine prefix if it's not Or am I misunderstanding how the Obok plugin works? |
I agree having it be configurable would be better, I was just trying to fix a series of bugs in the old implementation (and searching The issue is that (I believe this is a bug in the Kobo desktop application) on Linux, the Kobo Reader will always use the current directory as the place to dump all of the Kobo data files. I think this is only the case on Linux. This means if you run Kobo in |
Are you sure that that is the case? I've just downloaded Kobo Desktop onto my Linux machine, ran it through Wine from various different working directories, and it's always placed the "Kobo.sqlite" file into Maybe the bug has been fixed with newer Kobo Desktop versions or with newer Wine versions? |
What version of Kobo are you using and how are you starting it? I have the 2021/10/30 (9bb7fadc79) edition installed (I tried to redownload the installer but even with a Windows user agent the download button isn't working). There are warning messages in the log indicating that some environment variable is being set but some other code can't read it (and
I'm launching Kobo using |
I ran Kobo Desktop 4.24 which I found on some random website, as the download button isn't working for me either, with Wine 5.0. I'm going to see if I can find a newer Kobo and/or a newer Wine. EDIT: Managed to download the most recent Kobo Desktop 4.30.16653 (30.10.21) through a Windows VM, same behaviour. Still writes to the correct folder, and I don't see these error messages anywhere. Starting Kobo as usual, same way you are starting it. Maybe it is a regression somewhere between Wine 5 and Wine 7.4, but if that's the case, then that should be fixed in Wine and not by adding an unperformant hack like this to the plugin, imo. |
Here modify python source, that works under cygwin in command line: |
3f8a782
to
9ae77c4
Compare
dd9bb72
to
e3b4c9d
Compare
a716d25
to
10b6caf
Compare
The Kobo Desktop program will (when running under Wine on Linux) put all
of its data in the current working directory. This means that there
may be more than one Kobo.sqlite floating around by the user, which
leads to Obok showing an outdated list of books and the user being
confused by Obok cannot find the full list of books.
Solving this completely appears to be a bit too complicated, so this
patch is a best-effort improvement for the worst cases which can be
caused by this:
If the user deletes the files but Obok has already cached the path,
previously Obok would just error out rather than trying to search
for a new Kobo.sqlite path and updating the cache.
We search $HOME before searching /, which speeds up initial usage of
Obok in the common case (usually Kobo Desktop will be installed in
~/.wine/drive_c) and also ensures that we correctly preference the
current user's Kobo Desktop installation.
Signed-off-by: Aleksa Sarai [email protected]