Fix #2144340 [Ebook Previewer Reports Key Error Message After Book Reload](https://bugs.launchpad.net/calibre/+bug/2144340)

This commit is contained in:
Kovid Goyal 2026-03-13 21:57:55 +05:30
parent 925b8097c5
commit df3220ca10
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -98,10 +98,10 @@ class AnnotationsSaveWorker(Thread):
amap = current_book_data['annotations_map']
alist = tuple(annotations_as_copied_list(amap))
last_read_data = {}
if lr := amap.get('last-read'):
if (lr := amap.get('last-read')) and (pos_frac := current_book_data.get('pos_frac')) is not None:
last_read_data['cfi'] = lr[0]['pos']
last_read_data['timestamp'] = lr[0]['timestamp']
last_read_data['pos_frac'] = current_book_data['pos_frac'] or 0.0
last_read_data['pos_frac'] = pos_frac or 0.0
ebp = current_book_data['pathtoebook']
ext = ebp.rpartition('.')[-1].lower()
can_save_in_book_file = ext in ('epub', 'kepub')