mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-02 19:23:40 +01:00
calibre-server: Auto-create userdb directory if it does not exist
This commit is contained in:
parent
23fe6dc98b
commit
f5962cb392
1 changed files with 8 additions and 1 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Reference in a new issue