1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-11-22 18:04:50 +00:00

Improved error handling for renaming authors and titles (changes related to filesystem and not only to database)

This commit is contained in:
OzzieIsaacs
2017-11-30 16:49:46 +01:00
parent b4aede78bc
commit f1fac28203
18 changed files with 1249 additions and 1124 deletions

View File

@@ -14,17 +14,17 @@ BookMeta = namedtuple('BookMeta', 'file_path, extension, title, author, cover, d
"""
def upload(file):
def upload(uploadfile):
tmp_dir = os.path.join(gettempdir(), 'calibre_web')
if not os.path.isdir(tmp_dir):
os.mkdir(tmp_dir)
filename = file.filename
filename = uploadfile.filename
filename_root, file_extension = os.path.splitext(filename)
md5 = hashlib.md5()
md5.update(filename.encode('utf-8'))
tmp_file_path = os.path.join(tmp_dir, md5.hexdigest())
file.save(tmp_file_path)
uploadfile.save(tmp_file_path)
meta = book_formats.process(tmp_file_path, filename_root, file_extension)
return meta