make sqlite open errors clearer
if filesystem permissions on the directory the sqlite database database file is in are such that the app cannot list or create files, sqlite gives a vague error: ``` sqlite3.OperationalError: unable to open database file ``` whereas python's open() will give a better hint ("permission denied"). So, we try opening the database file with python first. also, add chmods to the startup scripts to avoid this issue in the future
This commit is contained in:
parent
f0b9074391
commit
e5158cfdc7
|
@ -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,7 +63,8 @@ class PysonicDatabase(object):
|
|||
self.scanner = PysonicFilesystemScanner(self)
|
||||
|
||||
def open(self):
|
||||
logging.debug("opening database: %s", self.path)
|
||||
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
|
||||
|
||||
|
@ -159,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):
|
||||
|
|
Loading…
Reference in New Issue