From ae439f110e61a18219c9dcd983dc3f4fe602cec2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Aug 2013 14:58:57 +0530 Subject: [PATCH] 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. --- src/calibre/db/cache.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py index 10ce4e75f5..11005ecf0b 100644 --- a/src/calibre/db/cache.py +++ b/src/calibre/db/cache.py @@ -1200,14 +1200,14 @@ class Cache(object): @api def add_format(self, book_id, fmt, stream_or_path, replace=True, run_hooks=True, dbapi=None): - with self.write_lock: - if run_hooks: - # Run import plugins - npath = run_import_plugins(stream_or_path, fmt) - fmt = os.path.splitext(npath)[-1].lower().replace('.', '').upper() - stream_or_path = lopen(npath, 'rb') - fmt = check_ebook_format(stream_or_path, fmt) + if run_hooks: + # Run import plugins + npath = run_import_plugins(stream_or_path, fmt) + fmt = os.path.splitext(npath)[-1].lower().replace('.', '').upper() + stream_or_path = lopen(npath, 'rb') + fmt = check_ebook_format(stream_or_path, fmt) + with self.write_lock: fmt = (fmt or '').upper() self.format_metadata_cache[book_id].pop(fmt, None) try: