From 03126d37f8aaec8085888a67405aa25ae50674b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 30 Aug 2018 07:57:21 +0530 Subject: [PATCH] ... --- src/calibre/srv/users.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/srv/users.py b/src/calibre/srv/users.py index 86e6b7a48f..42a3d57c36 100644 --- a/src/calibre/srv/users.py +++ b/src/calibre/srv/users.py @@ -76,8 +76,14 @@ def connect(path, exc_class=ValueError): pdir = os.path.dirname(path) if os.path.isdir(pdir): raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e))) - os.makedirs(pdir) - return apsw.Connection(path) + try: + os.makedirs(pdir) + except EnvironmentError as e: + raise exc_class('Failed to make directory for userdb database at {} with error: {}'.format(pdir, as_unicode(e))) + try: + return apsw.Connection(path) + except apsw.CantOpenError as e: + raise exc_class('Failed to open userdb database at {} with error: {}'.format(path, as_unicode(e))) class UserManager(object):