From f5962cb392d5699fc09eb7818bc57dd3ef1da33a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Dec 2017 14:15:18 +0530 Subject: [PATCH] calibre-server: Auto-create userdb directory if it does not exist --- src/calibre/srv/users.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/users.py b/src/calibre/srv/users.py index aaa6326cc4..8b04498146 100644 --- a/src/calibre/srv/users.py +++ b/src/calibre/srv/users.py @@ -76,7 +76,14 @@ class UserManager(object): def conn(self): with self.lock: if self._conn is None: - self._conn = apsw.Connection(self.path) + try: + self._conn = apsw.Connection(self.path) + except apsw.CantOpenError: + pdir = os.path.dirname(self.path) + if os.path.isdir(pdir): + raise + os.makedirs(pdir) + self._conn = apsw.Connection(self.path) with self._conn: c = self._conn.cursor() uv = next(c.execute('PRAGMA user_version'))[0]