mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Make the smart device cache return instances of USBMS.Book instead of Book.Metadata.
This commit is contained in:
parent
984c29c1e2
commit
f97ae35cc5
@ -688,7 +688,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
lastmod = parse_date(lastmod)
|
lastmod = parse_date(lastmod)
|
||||||
if key in self.known_uuids and self.known_uuids[key]['book'].last_modified == lastmod:
|
if key in self.known_uuids and self.known_uuids[key]['book'].last_modified == lastmod:
|
||||||
self.known_uuids[key]['last_used'] = now()
|
self.known_uuids[key]['last_used'] = now()
|
||||||
return self.known_uuids[key]['book'].deepcopy()
|
return self.known_uuids[key]['book'].deepcopy(lambda : SDBook('', ''))
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return None
|
return None
|
||||||
|
@ -184,11 +184,14 @@ class Metadata(object):
|
|||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
return key in object.__getattribute__(self, '_data')
|
return key in object.__getattribute__(self, '_data')
|
||||||
|
|
||||||
def deepcopy(self):
|
def deepcopy(self, class_generator=lambda : Metadata(None)):
|
||||||
''' Do not use this method unless you know what you are doing, if you
|
''' Do not use this method unless you know what you are doing, if you
|
||||||
want to create a simple clone of this object, use :meth:`deepcopy_metadata`
|
want to create a simple clone of this object, use :meth:`deepcopy_metadata`
|
||||||
instead. '''
|
instead. Class_generator must be a function that returns an instance
|
||||||
m = Metadata(None)
|
of Metadata or a subclass of it.'''
|
||||||
|
m = class_generator()
|
||||||
|
if not isinstance(m, Metadata):
|
||||||
|
return None
|
||||||
object.__setattr__(m, '__dict__', copy.deepcopy(self.__dict__))
|
object.__setattr__(m, '__dict__', copy.deepcopy(self.__dict__))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user