This commit is contained in:
Kovid Goyal 2013-01-15 16:13:00 +05:30
commit 440070ed94

View File

@ -391,7 +391,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
try: try:
# If we have already seen this book's UUID, use the existing path # If we have already seen this book's UUID, use the existing path
if self.settings().extra_customization[self.OPT_OVERWRITE_BOOKS_UUID]: if self.settings().extra_customization[self.OPT_OVERWRITE_BOOKS_UUID]:
existing_book = self._uuid_already_on_device(mdata.uuid) existing_book = self._uuid_already_on_device(mdata.uuid, ext)
if existing_book and existing_book.lpath: if existing_book and existing_book.lpath:
return existing_book.lpath return existing_book.lpath
@ -688,20 +688,24 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
return not v_thumb or v_thumb[1] == b_thumb[1] return not v_thumb or v_thumb[1] == b_thumb[1]
return False return False
def _uuid_already_on_device(self, uuid): def _uuid_already_on_device(self, uuid, ext):
return self.known_uuids.get(uuid, None) try:
return self.known_uuids.get(uuid + ext, None)
except:
return None
def _set_known_metadata(self, book, remove=False): def _set_known_metadata(self, book, remove=False):
lpath = book.lpath lpath = book.lpath
ext = os.path.splitext(lpath)[1]
uuid = book.get('uuid', None) uuid = book.get('uuid', None)
if remove: if remove:
self.known_metadata.pop(lpath, None) self.known_metadata.pop(lpath, None)
if uuid: if uuid and ext:
self.known_uuids.pop(uuid, None) self.known_uuids.pop(uuid+ext, None)
else: else:
new_book = self.known_metadata[lpath] = book.deepcopy() new_book = self.known_metadata[lpath] = book.deepcopy()
if uuid: if uuid and ext:
self.known_uuids[uuid] = new_book self.known_uuids[uuid+ext] = new_book
def _close_device_socket(self): def _close_device_socket(self):
if self.device_socket is not None: if self.device_socket is not None: