From 1c945b2d1948095619f5f4f59c13827bc379d4bd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 29 Mar 2015 08:14:26 +0530 Subject: [PATCH] ... --- src/calibre/gui2/actions/add.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index 686988aa90..94477f5df4 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -183,11 +183,13 @@ class AddAction(InterfaceAction): from calibre.ebooks.oeb.polish.create import create_book pt = PersistentTemporaryFile(suffix='.' + format_) pt.close() - mi = db.new_api.get_metadata(id_, get_cover=False, - get_user_categories=False, cover_as_data=False) - create_book(mi, pt.name, fmt=format_) - db.add_format_with_hooks(id_, format_, pt.name, index_is_id=True, notify=True) - os.remove(pt.name) + try: + mi = db.new_api.get_metadata(id_, get_cover=False, + get_user_categories=False, cover_as_data=False) + create_book(mi, pt.name, fmt=format_) + db.add_format_with_hooks(id_, format_, pt.name, index_is_id=True, notify=True) + finally: + os.remove(pt.name) current_idx = self.gui.library_view.currentIndex() if current_idx.isValid():