1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-24 17:10:31 +00:00

Bugfix upload book format with language to book without language

This commit is contained in:
Ozzie Isaacs 2024-07-21 09:44:32 +02:00
parent 2f515b725b
commit e33e4ac4ac

View File

@ -134,8 +134,9 @@ def edit_book(book_id):
# handle upload other formats from local disk
meta = upload_single_file(request, book, book_id)
# only merge metadata if file was uploaded and no error occurred (meta equals not false or none)
upload_format = False
if meta:
merge_metadata(to_save, meta)
upload_format = merge_metadata(to_save, meta)
# handle upload covers from local disk
cover_upload_success = upload_cover(request, book)
if cover_upload_success:
@ -179,7 +180,7 @@ def edit_book(book_id):
modify_date |= edit_book_publisher(to_save['publisher'], book)
# handle book languages
try:
modify_date |= edit_book_languages(to_save['languages'], book)
modify_date |= edit_book_languages(to_save['languages'], book, upload_format)
except ValueError as e:
flash(str(e), category="error")
edit_error = True
@ -575,6 +576,10 @@ def merge_metadata(to_save, meta):
to_save['author_name'] = ''
if to_save.get('book_title', "") == _('Unknown'):
to_save['book_title'] = ''
if not to_save["languages"] and meta.languages:
upload_language = True
else:
upload_language = False
for s_field, m_field in [
('tags', 'tags'), ('author_name', 'author'), ('series', 'series'),
('series_index', 'series_id'), ('languages', 'languages'),
@ -582,7 +587,7 @@ def merge_metadata(to_save, meta):
to_save[s_field] = to_save[s_field] or getattr(meta, m_field, '')
to_save["description"] = to_save["description"] or Markup(
getattr(meta, 'description', '')).unescape()
return upload_language
def identifier_list(to_save, book):
"""Generate a list of Identifiers from form information"""