mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Fix adding/deleting books and editing metadata not updating the main calibre book list automatically. Fixes #1761017 [Book added through content server are not shown in main program window until restart](https://bugs.launchpad.net/calibre/+bug/1761017)
This commit is contained in:
parent
60c8d6effe
commit
8dd4d7bb3d
@ -93,7 +93,7 @@ def cdb_add_book(ctx, rd, job_id, add_duplicates, filename, library_id):
|
|||||||
ans = {'title': mi.title, 'authors': mi.authors, 'languages': mi.languages, 'filename': filename, 'id': job_id}
|
ans = {'title': mi.title, 'authors': mi.authors, 'languages': mi.languages, 'filename': filename, 'id': job_id}
|
||||||
if ids:
|
if ids:
|
||||||
ans['book_id'] = ids[0]
|
ans['book_id'] = ids[0]
|
||||||
books_added(ids)
|
ctx.notify_changes(db.backend.library_path, books_added(ids))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ def cdb_delete_book(ctx, rd, book_ids, library_id):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPBadRequest('invalid book_ids: {}'.format(book_ids))
|
raise HTTPBadRequest('invalid book_ids: {}'.format(book_ids))
|
||||||
db.remove_books(ids)
|
db.remove_books(ids)
|
||||||
books_deleted(ids)
|
ctx.notify_changes(db.backend.library_path, books_deleted(ids))
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
@ -120,6 +120,7 @@ def cdb_set_cover(ctx, rd, book_id, library_id):
|
|||||||
raise HTTPForbidden('Cannot use the add book interface with a user who has per library restrictions')
|
raise HTTPForbidden('Cannot use the add book interface with a user who has per library restrictions')
|
||||||
rd.request_body_file.seek(0)
|
rd.request_body_file.seek(0)
|
||||||
dirtied = db.set_cover({book_id: rd.request_body_file})
|
dirtied = db.set_cover({book_id: rd.request_body_file})
|
||||||
|
ctx.notify_changes(db.backend.library_path, metadata(dirtied))
|
||||||
return tuple(dirtied)
|
return tuple(dirtied)
|
||||||
|
|
||||||
|
|
||||||
@ -160,5 +161,5 @@ def cdb_set_fields(ctx, rd, book_id, library_id):
|
|||||||
|
|
||||||
for field, value in changes.iteritems():
|
for field, value in changes.iteritems():
|
||||||
dirtied |= db.set_field(field, {book_id: value})
|
dirtied |= db.set_field(field, {book_id: value})
|
||||||
metadata(dirtied)
|
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}}
|
return {bid: book_as_json(db, book_id) for bid in (dirtied & loaded_book_ids) | {book_id}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user