Change quoting of downloaded filename
This commit is contained in:
@@ -1091,14 +1091,12 @@ def get_download_link(book_id, book_format, client):
|
|||||||
file_name = book.title
|
file_name = book.title
|
||||||
if len(book.authors) > 0:
|
if len(book.authors) > 0:
|
||||||
file_name = file_name + ' - ' + book.authors[0].name
|
file_name = file_name + ' - ' + book.authors[0].name
|
||||||
if client == "kindle":
|
file_name = get_valid_filename(file_name, replace_whitespace=False, force_unidecode=True)
|
||||||
file_name = get_valid_filename(file_name, replace_whitespace=False, force_unidecode=True)
|
quoted_file_name = file_name if client == "kindle" else quote(file_name)
|
||||||
else:
|
|
||||||
file_name = quote(get_valid_filename(file_name, replace_whitespace=False))
|
|
||||||
headers = Headers()
|
headers = Headers()
|
||||||
headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream")
|
headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream")
|
||||||
headers["Content-Disposition"] = ('attachment; filename="{}.{}"; filename*=UTF-8\'\'{}.{}').format(
|
headers["Content-Disposition"] = ('attachment; filename="{}.{}"; filename*=UTF-8\'\'{}.{}').format(
|
||||||
file_name, book_format, file_name, book_format)
|
file_name, book_format, quoted_file_name, book_format)
|
||||||
return do_download_file(book, book_format, client, data1, headers)
|
return do_download_file(book, book_format, client, data1, headers)
|
||||||
else:
|
else:
|
||||||
log.error("Book id {} not found for downloading".format(book_id))
|
log.error("Book id {} not found for downloading".format(book_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user