mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1968767 [JSONDecode Error when turning pages with space bar in the E-Book Viewer](https://bugs.launchpad.net/calibre/+bug/1968767)
This commit is contained in:
parent
28c9006729
commit
572c34b821
@ -38,13 +38,17 @@ def reading_rates_path():
|
||||
|
||||
def save_reading_rates(key, rates):
|
||||
path = reading_rates_path()
|
||||
existing = {}
|
||||
try:
|
||||
with open(path, 'rb') as f:
|
||||
raw = f.read()
|
||||
except OSError:
|
||||
existing = {}
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
existing = json.loads(raw)
|
||||
except Exception:
|
||||
pass
|
||||
existing.pop(key, None)
|
||||
existing[key] = rates
|
||||
while len(existing) > 50:
|
||||
|
Loading…
x
Reference in New Issue
Block a user