mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
newdb: Speed up set_metadata() by not committing the db after individual field writes
This commit is contained in:
parent
c6daf258be
commit
82d7bd3d57
@ -1084,11 +1084,6 @@ class Cache(object):
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
for field in ('rating', 'series_index', 'timestamp'):
|
|
||||||
val = getattr(mi, field)
|
|
||||||
if val is not None:
|
|
||||||
protected_set_field(field, val)
|
|
||||||
|
|
||||||
# force_changes has no effect on cover manipulation
|
# force_changes has no effect on cover manipulation
|
||||||
cdata = mi.cover_data[1]
|
cdata = mi.cover_data[1]
|
||||||
if cdata is None and isinstance(mi.cover, basestring) and mi.cover and os.access(mi.cover, os.R_OK):
|
if cdata is None and isinstance(mi.cover, basestring) and mi.cover and os.access(mi.cover, os.R_OK):
|
||||||
@ -1099,6 +1094,12 @@ 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})
|
||||||
|
|
||||||
|
with self.backend.conn: # Speed up set_metadata by not operating in autocommit mode
|
||||||
|
for field in ('rating', 'series_index', 'timestamp'):
|
||||||
|
val = getattr(mi, field)
|
||||||
|
if val is not None:
|
||||||
|
protected_set_field(field, val)
|
||||||
|
|
||||||
for field in ('author_sort', 'publisher', 'series', 'tags', 'comments',
|
for field in ('author_sort', 'publisher', 'series', 'tags', 'comments',
|
||||||
'languages', 'pubdate'):
|
'languages', 'pubdate'):
|
||||||
val = mi.get(field, None)
|
val = mi.get(field, None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user