From 76186773aa4590bb774464af52bc12e3919da763 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Sep 2014 18:17:27 +0530 Subject: [PATCH] Fix a bug that prevented post-import file type plugins from being run when adding books via the GUI --- src/calibre/gui2/add.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/add.py b/src/calibre/gui2/add.py index 6b6aa5a27c..4eb6fbf07e 100644 --- a/src/calibre/gui2/add.py +++ b/src/calibre/gui2/add.py @@ -7,6 +7,7 @@ from functools import partial from PyQt5.Qt import QThread, QObject, Qt, QProgressDialog, pyqtSignal, QTimer +from calibre.customize.ui import run_plugins_on_postimport from calibre.ptempfile import PersistentTemporaryDirectory from calibre.gui2.dialogs.progress import ProgressDialog from calibre.gui2 import (error_dialog, info_dialog, gprefs, @@ -268,8 +269,11 @@ class DBAdder(QObject): # {{{ for path in formats: fmt = os.path.splitext(path)[-1].replace('.', '').upper() with open(path, 'rb') as f: - self.db.add_format(id, fmt, f, index_is_id=True, - notify=False, replace=replace) + # At this point, the filetype on import plugins have already + # been run by the metadata reading code, so we only need to run + # the postimport plugins, on a successful add. + if self.db.add_format(id, fmt, f, index_is_id=True, notify=False, replace=replace): + run_plugins_on_postimport(self.db, id, fmt) # }}}