Merge pull request 'Make sqlite open errors clearer' (#1) from dpedu/db-debug into master
All checks were successful
Gitea/pysonic/pipeline/head This commit looks good

Reviewed-on: #1
This commit is contained in:
dave 2022-12-24 14:41:44 -08:00
commit 092c833c4f
2 changed files with 9 additions and 4 deletions

View File

@ -10,7 +10,7 @@ from collections import Iterable
from pysonic.scanner import PysonicFilesystemScanner
logging = logging.getLogger("database")
logger = logging.getLogger("database")
LETTER_GROUPS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
@ -63,6 +63,8 @@ class PysonicDatabase(object):
self.scanner = PysonicFilesystemScanner(self)
def open(self):
with open(self.path, "rb"): # sqlite doesn't give very descriptive permission errors, but this does
pass
self.db = sqlite3.connect(self.path, **self.sqlite_opts)
self.db.row_factory = dict_factory
@ -158,14 +160,14 @@ class PysonicDatabase(object):
# Initialize DB
if len(c.fetchall()) == 0:
logging.warning("Initializing database")
logger.warning("Initializing database")
for query in queries:
c.execute(query)
c.execute("COMMIT")
else:
# Migrate if old db exists
# c.execute("""UPDATE meta SET value=? WHERE key="db_version";""", (str(version), ))
# logging.warning("db schema is version {}".format(version))
# logger.warning("db schema is version {}".format(version))
pass
def get_artist_info(self, item_id):

View File

@ -1,5 +1,8 @@
#!/bin/bash
chown -R app:app /db/
set -x
chmod 755 /db/.
chown -R app:app /db
exec sudo --preserve-env -Hu app pysonicd $@