2
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-10 01:13:33 +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 # handle upload other formats from local disk
meta = upload_single_file(request, book, book_id) 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) # only merge metadata if file was uploaded and no error occurred (meta equals not false or none)
upload_format = False
if meta: if meta:
merge_metadata(to_save, meta) upload_format = merge_metadata(to_save, meta)
# handle upload covers from local disk # handle upload covers from local disk
cover_upload_success = upload_cover(request, book) cover_upload_success = upload_cover(request, book)
if cover_upload_success: if cover_upload_success:
@ -179,7 +180,7 @@ def edit_book(book_id):
modify_date |= edit_book_publisher(to_save['publisher'], book) modify_date |= edit_book_publisher(to_save['publisher'], book)
# handle book languages # handle book languages
try: 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: except ValueError as e:
flash(str(e), category="error") flash(str(e), category="error")
edit_error = True edit_error = True
@ -575,6 +576,10 @@ def merge_metadata(to_save, meta):
to_save['author_name'] = '' to_save['author_name'] = ''
if to_save.get('book_title', "") == _('Unknown'): if to_save.get('book_title', "") == _('Unknown'):
to_save['book_title'] = '' 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 [ for s_field, m_field in [
('tags', 'tags'), ('author_name', 'author'), ('series', 'series'), ('tags', 'tags'), ('author_name', 'author'), ('series', 'series'),
('series_index', 'series_id'), ('languages', 'languages'), ('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[s_field] = to_save[s_field] or getattr(meta, m_field, '')
to_save["description"] = to_save["description"] or Markup( to_save["description"] = to_save["description"] or Markup(
getattr(meta, 'description', '')).unescape() getattr(meta, 'description', '')).unescape()
return upload_language
def identifier_list(to_save, book): def identifier_list(to_save, book):
"""Generate a list of Identifiers from form information""" """Generate a list of Identifiers from form information"""