From 09122265fde6b4b276a92c3f06deb9521e26c2ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 2 Apr 2012 17:31:45 +0530 Subject: [PATCH] ... --- src/calibre/gui2/actions/edit_metadata.py | 12 +++++++----- src/calibre/gui2/metadata/bulk_download.py | 4 ---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/calibre/gui2/actions/edit_metadata.py b/src/calibre/gui2/actions/edit_metadata.py index 4a0d12e3d3..3eb9a79122 100644 --- a/src/calibre/gui2/actions/edit_metadata.py +++ b/src/calibre/gui2/actions/edit_metadata.py @@ -96,10 +96,11 @@ class EditMetadataAction(InterfaceAction): if aborted: return self.cleanup_bulk_download(tdir) if all_failed: + num = len(failed_ids | failed_covers) self.cleanup_bulk_download(tdir) return error_dialog(self.gui, _('Download failed'), _('Failed to download metadata or covers for any of the %d' - ' book(s).') % len(id_map), det_msg=det_msg, show=True) + ' book(s).') % num, det_msg=det_msg, show=True) self.gui.status_bar.show_message(_('Metadata download completed'), 3000) @@ -498,7 +499,7 @@ class EditMetadataAction(InterfaceAction): self.apply_id_map = list(id_map.iteritems()) self.apply_current_idx = 0 self.apply_failures = [] - self.applied_ids = [] + self.applied_ids = set() self.apply_pd = None self.apply_callback = callback if len(self.apply_id_map) > 1: @@ -525,6 +526,7 @@ class EditMetadataAction(InterfaceAction): if cover: self.gui.current_db.set_cover(i, open(cover, 'rb'), notify=False, commit=False) + self.applied_ids.add(i) else: self.apply_mi(i, mi) @@ -554,7 +556,7 @@ class EditMetadataAction(InterfaceAction): mi.tags = list(set(tags)) db.set_metadata(book_id, mi, commit=False, set_title=set_title, set_authors=set_authors, notify=False) - self.applied_ids.append(book_id) + self.applied_ids.add(book_id) except: import traceback self.apply_failures.append((book_id, traceback.format_exc())) @@ -589,7 +591,7 @@ class EditMetadataAction(InterfaceAction): if self.applied_ids: cr = self.gui.library_view.currentIndex().row() self.gui.library_view.model().refresh_ids( - self.applied_ids, cr) + list(self.applied_ids), cr) if self.gui.cover_flow: self.gui.cover_flow.dataChanged() self.gui.tags_view.recount() @@ -598,7 +600,7 @@ class EditMetadataAction(InterfaceAction): self.apply_pd = None try: if callable(self.apply_callback): - self.apply_callback(self.applied_ids) + self.apply_callback(list(self.applied_ids)) finally: self.apply_callback = None diff --git a/src/calibre/gui2/metadata/bulk_download.py b/src/calibre/gui2/metadata/bulk_download.py index 3487ffd8f2..0f7097a4e6 100644 --- a/src/calibre/gui2/metadata/bulk_download.py +++ b/src/calibre/gui2/metadata/bulk_download.py @@ -169,10 +169,6 @@ class HeartBeat(object): self.last_time = time.time() return True -# Fix log viewer, ratings -# Test: abort, covers only, metadata only, both, 200 entry download, memory -# consumption, all errors and on and on - def download(all_ids, tf, db, do_identify, covers, ensure_fields, log=None, abort=None, notifications=None): batch_size = 10