mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-23 14:36:15 +01:00
Fix #1603 (traceback on adding multiple books from directories, each directory single book with multiple versions)
This commit is contained in:
parent
7af0e4b7fc
commit
4dc946d79b
2 changed files with 9 additions and 4 deletions
|
|
@ -1551,9 +1551,6 @@ def import_book_directory(self, dirpath, callback=None):
|
|||
|
||||
|
||||
|
||||
def has_book(self, mi):
|
||||
return bool(self.conn.get('SELECT id FROM books where title=?', (mi.title,), all=False))
|
||||
|
||||
def has_id(self, id):
|
||||
return self.conn.get('SELECT id FROM books where id=?', (id,), all=False) is not None
|
||||
|
||||
|
|
|
|||
|
|
@ -561,7 +561,15 @@ def cover(self, index, index_is_id=False, as_file=False, as_image=False):
|
|||
img.loadFromData(f.read())
|
||||
return img
|
||||
return f if as_file else f.read()
|
||||
|
||||
|
||||
def has_book(self, mi):
|
||||
title = mi.title
|
||||
if title:
|
||||
if not isinstance(title, unicode):
|
||||
title = title.decode(preferred_encoding, 'replace')
|
||||
return bool(self.conn.get('SELECT id FROM books where title=?', (title,), all=False))
|
||||
return False
|
||||
|
||||
def has_cover(self, index, index_is_id=False):
|
||||
id = index if index_is_id else self.id(index)
|
||||
path = os.path.join(self.library_path, self.path(id, index_is_id=True), 'cover.jpg')
|
||||
|
|
|
|||
Loading…
Reference in a new issue