This commit is contained in:
Kovid Goyal 2012-04-02 17:31:45 +05:30
parent d5ae96dc4c
commit 09122265fd
2 changed files with 7 additions and 9 deletions

View File

@ -96,10 +96,11 @@ class EditMetadataAction(InterfaceAction):
if aborted: if aborted:
return self.cleanup_bulk_download(tdir) return self.cleanup_bulk_download(tdir)
if all_failed: if all_failed:
num = len(failed_ids | failed_covers)
self.cleanup_bulk_download(tdir) self.cleanup_bulk_download(tdir)
return error_dialog(self.gui, _('Download failed'), return error_dialog(self.gui, _('Download failed'),
_('Failed to download metadata or covers for any of the %d' _('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) 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_id_map = list(id_map.iteritems())
self.apply_current_idx = 0 self.apply_current_idx = 0
self.apply_failures = [] self.apply_failures = []
self.applied_ids = [] self.applied_ids = set()
self.apply_pd = None self.apply_pd = None
self.apply_callback = callback self.apply_callback = callback
if len(self.apply_id_map) > 1: if len(self.apply_id_map) > 1:
@ -525,6 +526,7 @@ class EditMetadataAction(InterfaceAction):
if cover: if cover:
self.gui.current_db.set_cover(i, open(cover, 'rb'), self.gui.current_db.set_cover(i, open(cover, 'rb'),
notify=False, commit=False) notify=False, commit=False)
self.applied_ids.add(i)
else: else:
self.apply_mi(i, mi) self.apply_mi(i, mi)
@ -554,7 +556,7 @@ class EditMetadataAction(InterfaceAction):
mi.tags = list(set(tags)) mi.tags = list(set(tags))
db.set_metadata(book_id, mi, commit=False, set_title=set_title, db.set_metadata(book_id, mi, commit=False, set_title=set_title,
set_authors=set_authors, notify=False) set_authors=set_authors, notify=False)
self.applied_ids.append(book_id) self.applied_ids.add(book_id)
except: except:
import traceback import traceback
self.apply_failures.append((book_id, traceback.format_exc())) self.apply_failures.append((book_id, traceback.format_exc()))
@ -589,7 +591,7 @@ class EditMetadataAction(InterfaceAction):
if self.applied_ids: if self.applied_ids:
cr = self.gui.library_view.currentIndex().row() cr = self.gui.library_view.currentIndex().row()
self.gui.library_view.model().refresh_ids( self.gui.library_view.model().refresh_ids(
self.applied_ids, cr) list(self.applied_ids), cr)
if self.gui.cover_flow: if self.gui.cover_flow:
self.gui.cover_flow.dataChanged() self.gui.cover_flow.dataChanged()
self.gui.tags_view.recount() self.gui.tags_view.recount()
@ -598,7 +600,7 @@ class EditMetadataAction(InterfaceAction):
self.apply_pd = None self.apply_pd = None
try: try:
if callable(self.apply_callback): if callable(self.apply_callback):
self.apply_callback(self.applied_ids) self.apply_callback(list(self.applied_ids))
finally: finally:
self.apply_callback = None self.apply_callback = None

View File

@ -169,10 +169,6 @@ class HeartBeat(object):
self.last_time = time.time() self.last_time = time.time()
return True 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, def download(all_ids, tf, db, do_identify, covers, ensure_fields,
log=None, abort=None, notifications=None): log=None, abort=None, notifications=None):
batch_size = 10 batch_size = 10