mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Ensure that an error in set_metadata does not cause the memory and disk
data to diverge
This commit is contained in:
parent
82d7bd3d57
commit
2fd8022e9e
@ -1094,6 +1094,7 @@ class Cache(object):
|
|||||||
if cdata is not None:
|
if cdata is not None:
|
||||||
self._set_cover({book_id: cdata})
|
self._set_cover({book_id: cdata})
|
||||||
|
|
||||||
|
try:
|
||||||
with self.backend.conn: # Speed up set_metadata by not operating in autocommit mode
|
with self.backend.conn: # Speed up set_metadata by not operating in autocommit mode
|
||||||
for field in ('rating', 'series_index', 'timestamp'):
|
for field in ('rating', 'series_index', 'timestamp'):
|
||||||
val = getattr(mi, field)
|
val = getattr(mi, field)
|
||||||
@ -1136,6 +1137,9 @@ class Cache(object):
|
|||||||
extra = mi.get_extra(key)
|
extra = mi.get_extra(key)
|
||||||
if extra is not None or force_changes:
|
if extra is not None or force_changes:
|
||||||
protected_set_field(idx, extra)
|
protected_set_field(idx, extra)
|
||||||
|
except:
|
||||||
|
self._reload_from_db()
|
||||||
|
raise
|
||||||
|
|
||||||
@write_api
|
@write_api
|
||||||
def add_format(self, book_id, fmt, stream_or_path, replace=True, run_hooks=True, dbapi=None):
|
def add_format(self, book_id, fmt, stream_or_path, replace=True, run_hooks=True, dbapi=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user