mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
Fixes #1238887 [Smart Device Control failes with Errno 2 No such file or directory: <path>\\AppData\\Local\\calibre-cache\\device_drivers_SMART_DEVICE_APP_metadata_cache.json'](https://bugs.launchpad.net/calibre/+bug/1238887)
This commit is contained in:
commit
424b9e1884
@ -730,27 +730,28 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
'_metadata_cache.json')
|
'_metadata_cache.json')
|
||||||
self.known_uuids = defaultdict(dict)
|
self.known_uuids = defaultdict(dict)
|
||||||
self.known_metadata = {}
|
self.known_metadata = {}
|
||||||
with open(cache_file_name, mode='rb') as fd:
|
if os.path.exists(cache_file_name):
|
||||||
try:
|
with open(cache_file_name, mode='rb') as fd:
|
||||||
while True:
|
try:
|
||||||
rec_len = fd.readline()
|
while True:
|
||||||
if len(rec_len) != 8:
|
rec_len = fd.readline()
|
||||||
break
|
if len(rec_len) != 8:
|
||||||
raw = fd.read(int(rec_len))
|
break
|
||||||
book = json.loads(raw.decode('utf-8'), object_hook=from_json)
|
raw = fd.read(int(rec_len))
|
||||||
uuid = book.keys()[0]
|
book = json.loads(raw.decode('utf-8'), object_hook=from_json)
|
||||||
metadata = self.json_codec.raw_to_book(book[uuid]['book'],
|
uuid = book.keys()[0]
|
||||||
SDBook, self.PREFIX)
|
metadata = self.json_codec.raw_to_book(book[uuid]['book'],
|
||||||
book[uuid]['book'] = metadata
|
SDBook, self.PREFIX)
|
||||||
self.known_uuids.update(book)
|
book[uuid]['book'] = metadata
|
||||||
|
self.known_uuids.update(book)
|
||||||
|
|
||||||
lpath = metadata.get('lpath')
|
lpath = metadata.get('lpath')
|
||||||
if lpath in self.known_metadata:
|
if lpath in self.known_metadata:
|
||||||
self.known_uuids.pop(uuid, None)
|
self.known_uuids.pop(uuid, None)
|
||||||
else:
|
else:
|
||||||
self.known_metadata[lpath] = metadata
|
self.known_metadata[lpath] = metadata
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def _write_metadata_cache(self):
|
def _write_metadata_cache(self):
|
||||||
from calibre.utils.config import to_json
|
from calibre.utils.config import to_json
|
||||||
|
Loading…
x
Reference in New Issue
Block a user