mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-09 11:30:00 +00:00
Output error message in case import of libmagic fails (#3104)
This commit is contained in:
parent
e3be7595e2
commit
a59d20bd0f
@ -29,8 +29,9 @@ log = logger.create()
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import magic
|
import magic
|
||||||
|
error = None
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
log.error("Cannot import python-magic, checking uploaded file metadata will not work: %s", e)
|
error = "Cannot import python-magic, checking uploaded file metadata will not work: {}".format(e)
|
||||||
|
|
||||||
|
|
||||||
def get_temp_dir():
|
def get_temp_dir():
|
||||||
@ -46,6 +47,9 @@ def del_temp_dir():
|
|||||||
|
|
||||||
|
|
||||||
def validate_mime_type(file_buffer, allowed_extensions):
|
def validate_mime_type(file_buffer, allowed_extensions):
|
||||||
|
if error:
|
||||||
|
log.error(error)
|
||||||
|
return False
|
||||||
mime = magic.Magic(mime=True)
|
mime = magic.Magic(mime=True)
|
||||||
allowed_mimetypes = list()
|
allowed_mimetypes = list()
|
||||||
for x in allowed_extensions:
|
for x in allowed_extensions:
|
||||||
|
Loading…
Reference in New Issue
Block a user