calibre-server: Auto-create userdb directory if it does not exist

This commit is contained in:
Kovid Goyal 2017-12-05 14:15:18 +05:30
parent 23fe6dc98b
commit f5962cb392
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -76,6 +76,13 @@ class UserManager(object):
def conn(self):
with self.lock:
if self._conn is None:
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()