Commit eaed53e2 authored by Ozzieisaacs's avatar Ozzieisaacs

Fix for author edit error (2 same sort_authors lead maybe to choose wrong one)

parent feacbe8e
...@@ -593,13 +593,16 @@ class CalibreDB(): ...@@ -593,13 +593,16 @@ class CalibreDB():
sort_authors = entry.author_sort.split('&') sort_authors = entry.author_sort.split('&')
authors_ordered = list() authors_ordered = list()
error = False error = False
ids = [a.id for a in entry.authors]
for auth in sort_authors: for auth in sort_authors:
results = self.session.query(Authors).filter(Authors.sort == auth.lstrip().strip()).all()
# ToDo: How to handle not found authorname # ToDo: How to handle not found authorname
result = self.session.query(Authors).filter(Authors.sort == auth.lstrip().strip()).first() if not len(results):
if not result:
error = True error = True
break break
authors_ordered.append(result) for r in results:
if r.id in ids:
authors_ordered.append(r)
if not error: if not error:
entry.authors = authors_ordered entry.authors = authors_ordered
return entry return entry
......
...@@ -684,6 +684,7 @@ def edit_book(book_id): ...@@ -684,6 +684,7 @@ def edit_book(book_id):
if modif_date: if modif_date:
book.last_modified = datetime.utcnow() book.last_modified = datetime.utcnow()
calibre_db.session.merge(book)
calibre_db.session.commit() calibre_db.session.commit()
if config.config_use_google_drive: if config.config_use_google_drive:
gdriveutils.updateGdriveCalibreFromLocal() gdriveutils.updateGdriveCalibreFromLocal()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment