mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1455746 [FileTypePlugin receives old database API object](https://bugs.launchpad.net/calibre/+bug/1455746)
This commit is contained in:
parent
036fa88a5a
commit
191d204412
@ -113,7 +113,7 @@ def recursive_import(db, root, single_book_per_directory=True,
|
|||||||
break
|
break
|
||||||
return duplicates
|
return duplicates
|
||||||
|
|
||||||
def add_catalog(cache, path, title):
|
def add_catalog(cache, path, title, dbapi=None):
|
||||||
from calibre.ebooks.metadata.book.base import Metadata
|
from calibre.ebooks.metadata.book.base import Metadata
|
||||||
from calibre.ebooks.metadata.meta import get_metadata
|
from calibre.ebooks.metadata.meta import get_metadata
|
||||||
from calibre.utils.date import utcnow
|
from calibre.utils.date import utcnow
|
||||||
@ -142,11 +142,11 @@ def add_catalog(cache, path, title):
|
|||||||
new_book_added = True
|
new_book_added = True
|
||||||
else:
|
else:
|
||||||
cache._set_metadata(db_id, mi)
|
cache._set_metadata(db_id, mi)
|
||||||
cache.add_format(db_id, fmt, stream) # Cant keep write lock since post-import hooks might run
|
cache.add_format(db_id, fmt, stream, dbapi=dbapi) # Cant keep write lock since post-import hooks might run
|
||||||
|
|
||||||
return db_id, new_book_added
|
return db_id, new_book_added
|
||||||
|
|
||||||
def add_news(cache, path, arg):
|
def add_news(cache, path, arg, dbapi=None):
|
||||||
from calibre.ebooks.metadata.meta import get_metadata
|
from calibre.ebooks.metadata.meta import get_metadata
|
||||||
from calibre.utils.date import utcnow
|
from calibre.utils.date import utcnow
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ def add_news(cache, path, arg):
|
|||||||
mi.timestamp = utcnow()
|
mi.timestamp = utcnow()
|
||||||
|
|
||||||
db_id = cache._create_book_entry(mi, apply_import_tags=False)
|
db_id = cache._create_book_entry(mi, apply_import_tags=False)
|
||||||
cache.add_format(db_id, fmt, stream) # Cant keep write lock since post-import hooks might run
|
cache.add_format(db_id, fmt, stream, dbapi=dbapi) # Cant keep write lock since post-import hooks might run
|
||||||
|
|
||||||
if not hasattr(path, 'read'):
|
if not hasattr(path, 'read'):
|
||||||
stream.close()
|
stream.close()
|
||||||
|
@ -259,13 +259,13 @@ class LibraryDatabase(object):
|
|||||||
return recursive_import(self, root, single_book_per_directory=single_book_per_directory, callback=callback, added_ids=added_ids)
|
return recursive_import(self, root, single_book_per_directory=single_book_per_directory, callback=callback, added_ids=added_ids)
|
||||||
|
|
||||||
def add_catalog(self, path, title):
|
def add_catalog(self, path, title):
|
||||||
book_id, new_book_added = add_catalog(self.new_api, path, title)
|
book_id, new_book_added = add_catalog(self.new_api, path, title, dbapi=self)
|
||||||
if book_id is not None and new_book_added:
|
if book_id is not None and new_book_added:
|
||||||
self.data.books_added((book_id,))
|
self.data.books_added((book_id,))
|
||||||
return book_id
|
return book_id
|
||||||
|
|
||||||
def add_news(self, path, arg):
|
def add_news(self, path, arg):
|
||||||
book_id = add_news(self.new_api, path, arg)
|
book_id = add_news(self.new_api, path, arg, dbapi=self)
|
||||||
if book_id is not None:
|
if book_id is not None:
|
||||||
self.data.books_added((book_id,))
|
self.data.books_added((book_id,))
|
||||||
return book_id
|
return book_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user