mirror of
https://github.com/JonathanHerrewijnen/calibre-web.git
synced 2024-11-13 06:34:26 +00:00
improvements for pdf upload function
This commit is contained in:
parent
3324669702
commit
bda3055a19
@ -189,11 +189,13 @@ def update_dir_stucture(book_id):
|
|||||||
new_titledir = get_valid_filename(book.title, False) + " (" + str(book_id) + ")"
|
new_titledir = get_valid_filename(book.title, False) + " (" + str(book_id) + ")"
|
||||||
|
|
||||||
if titledir != new_titledir:
|
if titledir != new_titledir:
|
||||||
os.rename(path, os.path.join(os.path.dirname(path), new_titledir))
|
new_title_path = os.path.join(os.path.dirname(path), new_titledir)
|
||||||
path = os.path.join(os.path.dirname(path), new_titledir)
|
os.rename(path, new_title_path)
|
||||||
|
path = new_title_path
|
||||||
book.path = book.path.split("/")[0] + "/" + new_titledir
|
book.path = book.path.split("/")[0] + "/" + new_titledir
|
||||||
|
|
||||||
if authordir != new_authordir:
|
if authordir != new_authordir:
|
||||||
os.renames(path, os.path.join(os.path.join(config.DB_ROOT, new_authordir), os.path.basename(path)))
|
new_author_path = os.path.join(os.path.join(config.DB_ROOT, new_authordir), os.path.basename(path))
|
||||||
|
os.renames(path, new_author_path)
|
||||||
book.path = new_authordir + "/" + book.path.split("/")[1]
|
book.path = new_authordir + "/" + book.path.split("/")[1]
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
<div class="discover load-more">
|
<div class="discover load-more">
|
||||||
<h2>{{title}}</h2>
|
<h2>{{title}}</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<div class="col-sm-3 col-lg-2 col-xs-6 book">
|
<div class="col-sm-3 col-lg-2 col-xs-6 book">
|
||||||
<div class="cover">
|
<div class="cover">
|
||||||
|
@ -760,6 +760,9 @@ def upload():
|
|||||||
if fileextension.upper() == ".PDF":
|
if fileextension.upper() == ".PDF":
|
||||||
title = filename_root
|
title = filename_root
|
||||||
author = "Unknown"
|
author = "Unknown"
|
||||||
|
else:
|
||||||
|
flash("Upload is only available for PDF files", category="error")
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
title_dir = helper.get_valid_filename(title, False)
|
title_dir = helper.get_valid_filename(title, False)
|
||||||
author_dir = helper.get_valid_filename(author.decode('utf-8'), False)
|
author_dir = helper.get_valid_filename(author.decode('utf-8'), False)
|
||||||
|
Loading…
Reference in New Issue
Block a user