Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .cli import CliParameter
from .constants import CONFIG_DIR
from .reverseproxy import ReverseProxied
from .subproc_wrapper import process_open
from .server import WebServer
from .dep_check import dependency_check
from .updater import Updater
Expand Down Expand Up @@ -152,6 +153,12 @@ def create_app():
db.CalibreDB.setup_db(config.config_calibre_dir, cli_param.settings_path)
calibre_db.init_db()

XKLB_PATCH = os.getenv('XKLB_PATCH', 'xklb-patch')
p = process_open([XKLB_PATCH], newlines=True)
while p.poll is None:
log.info(p.stdout.readline())
p.wait()

updater_thread.init_updater(config, web_server)
# Perform dry run of updater and exit afterward
if cli_param.dry_run:
Expand Down
19 changes: 19 additions & 0 deletions scripts/xklb-patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# FILE_PATH="$HOME/.local/pipx/venvs/xklb/lib/python3.12/site-packages/xklb/createdb/tube_add.py"
# Debian 12 and Ubuntu 23.10 use: /root/.local/pipx/...
# Debian 13 and Ubuntu 24.04 use: /root/.local/share/pipx/...
# Running 'updatedb' is an ugly hack that might be very slow (optimize later!)
# but at least fixes (a) "share" in path on new OS's (b) Python version in path
updatedb
Comment thread
deldesir marked this conversation as resolved.
Outdated
FILE_PATH=$(locate /site-packages/xklb/mediadb/db_media.py | grep /pipx/venvs/xklb/lib/ | grep '/root/.local' | head -1)

# Check if the patch has already been applied
if grep -q 'entry = {k: v for k, v in entry.items() if v is not None or k == "error"}' "$FILE_PATH"; then
echo "db_media.py already patched to retain 'error' key when value is None. No changes necessary."
else
echo "Patching db_media.py to ensure 'error' key is retained even when its value is None."
sed -i.bak 's/entry = objects\.dict_filter_bool(entry)/entry = {k: v for k, v in entry.items() if v is not None or k == "error"}/' "$FILE_PATH"

echo "db_media.py has been successfully patched."
fi