From e606618d0469bbb5f6204bed73a73e644d2ea7e2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Oct 2012 08:53:19 +0530 Subject: [PATCH 1/2] MTP driver: Ignore errors when getting the driveinfo.calibre file from the device and simply regenerate it --- src/calibre/devices/mtp/driver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/mtp/driver.py b/src/calibre/devices/mtp/driver.py index be2bab7638..1584a3bf93 100644 --- a/src/calibre/devices/mtp/driver.py +++ b/src/calibre/devices/mtp/driver.py @@ -108,10 +108,12 @@ class MTP_DEVICE(BASE): f = storage.find_path((self.DRIVEINFO,)) dinfo = {} if f is not None: - stream = self.get_mtp_file(f) try: + stream = self.get_mtp_file(f) dinfo = json.load(stream, object_hook=from_json) except: + prints('Failed to load existing driveinfo.calibre file, with error:') + traceback.print_exc() dinfo = None if dinfo.get('device_store_uuid', None) is None: dinfo['device_store_uuid'] = unicode(uuid.uuid4()) From 8c945042369d8047b5f34ebf8e2a0e5323de1f75 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 10 Oct 2012 09:40:49 +0530 Subject: [PATCH 2/2] Metadata download dialog: Fix selected cover being changed when covers are re-sorted after download completes --- src/calibre/gui2/metadata/single_download.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 11f1b4a339..cff1527b6f 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -678,11 +678,12 @@ class CoversModel(QAbstractListModel): # {{{ good = [] pmap = {} dcovers = sorted(self.covers[1:], key=self.cover_keygen, reverse=True) + cmap = {x:self.covers.index(x) for x in self.covers} for i, x in enumerate(self.covers[0:1] + dcovers): if not x[-1]: good.append(x) if i > 0: - plugin = self.plugin_for_index(i) + plugin = self.plugin_for_index(cmap[x]) pmap[plugin] = len(good) - 1 self.covers = good self.plugin_map = pmap