Fix for broken file type plugins

Prevent file type plugins that spin the event loop by displaying a
dialog from causing locking errors. The lock is now acquired only after
the file type plugin has run on import.
This commit is contained in:
Kovid Goyal 2013-08-30 14:58:57 +05:30
parent 610f29d223
commit ae439f110e

View File

@ -1200,7 +1200,6 @@ class Cache(object):
@api @api
def add_format(self, book_id, fmt, stream_or_path, replace=True, run_hooks=True, dbapi=None): def add_format(self, book_id, fmt, stream_or_path, replace=True, run_hooks=True, dbapi=None):
with self.write_lock:
if run_hooks: if run_hooks:
# Run import plugins # Run import plugins
npath = run_import_plugins(stream_or_path, fmt) npath = run_import_plugins(stream_or_path, fmt)
@ -1208,6 +1207,7 @@ class Cache(object):
stream_or_path = lopen(npath, 'rb') stream_or_path = lopen(npath, 'rb')
fmt = check_ebook_format(stream_or_path, fmt) fmt = check_ebook_format(stream_or_path, fmt)
with self.write_lock:
fmt = (fmt or '').upper() fmt = (fmt or '').upper()
self.format_metadata_cache[book_id].pop(fmt, None) self.format_metadata_cache[book_id].pop(fmt, None)
try: try: