From 0c67fd43a29b819325007aa0e0487821ca1e1821 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 8 Oct 2015 10:59:34 +0900 Subject: [PATCH] obok: make sure that file exists before opening the db --- Obok_calibre_plugin/obok_plugin/obok/obok.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Obok_calibre_plugin/obok_plugin/obok/obok.py b/Obok_calibre_plugin/obok_plugin/obok/obok.py index 04b9075..4e884e7 100644 --- a/Obok_calibre_plugin/obok_plugin/obok/obok.py +++ b/Obok_calibre_plugin/obok_plugin/obok/obok.py @@ -260,7 +260,7 @@ class KoboLibrary(object): self.kobodir = os.path.join(device_path, u".kobo") # devices use KoboReader.sqlite kobodb = os.path.join(self.kobodir, u"KoboReader.sqlite") - if (not(os.path.exists(kobodb))): + if (not(os.path.isfile(kobodb))): # give up here, we haven't found anything useful self.kobodir = u"" kobodb = u"" @@ -282,6 +282,12 @@ class KoboLibrary(object): self.kobodir = os.path.join(os.environ['HOME'], u"Library", u"Application Support", u"Kobo", u"Kobo Desktop Edition") # desktop versions use Kobo.sqlite kobodb = os.path.join(self.kobodir, u"Kobo.sqlite") + # check for existence of file + if (not(os.path.isfile(kobodb))): + # give up here, we haven't found anything useful + self.kobodir = u"" + kobodb = u"" + if (self.kobodir != u""): self.bookdir = os.path.join(self.kobodir, u"kepub")