mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a flag to cdb/set-fields to avoid needing to pass all book ids for dirtied updates
This commit is contained in:
parent
eab43eb63e
commit
8fbdd7bc9a
@ -144,6 +144,7 @@ def cdb_set_fields(ctx, rd, book_id, library_id):
|
||||
raise HTTPBadRequest('Invalid encoded data')
|
||||
try:
|
||||
changes, loaded_book_ids = data['changes'], frozenset(map(int, data.get('loaded_book_ids', ())))
|
||||
all_dirtied = bool(data.get('all_dirtied'))
|
||||
if not isinstance(changes, dict):
|
||||
raise TypeError('changes must be a dict')
|
||||
except Exception:
|
||||
@ -168,4 +169,6 @@ def cdb_set_fields(ctx, rd, book_id, library_id):
|
||||
for field, value in changes.iteritems():
|
||||
dirtied |= db.set_field(field, {book_id: value})
|
||||
ctx.notify_changes(db.backend.library_path, metadata(dirtied))
|
||||
return {bid: book_as_json(db, book_id) for bid in (dirtied & loaded_book_ids) | {book_id}}
|
||||
all_ids = dirtied if all_dirtied else (dirtied & loaded_book_ids)
|
||||
all_ids |= {book_id}
|
||||
return {bid: book_as_json(db, book_id) for bid in all_ids}
|
||||
|
Loading…
x
Reference in New Issue
Block a user