|
|
@ -48,11 +48,17 @@ from shutil import move, copyfile
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
from tornado import version as tornadoVersion
|
|
|
|
from tornado import version as tornadoVersion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
from imp import reload
|
|
|
|
|
|
|
|
from past.builtins import xrange
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from wand.image import Image
|
|
|
|
from wand.image import Image
|
|
|
|
|
|
|
|
|
|
|
|
use_generic_pdf_cover = False
|
|
|
|
use_generic_pdf_cover = False
|
|
|
|
except ImportError, e:
|
|
|
|
except ImportError as e:
|
|
|
|
use_generic_pdf_cover = True
|
|
|
|
use_generic_pdf_cover = True
|
|
|
|
from cgi import escape
|
|
|
|
from cgi import escape
|
|
|
|
|
|
|
|
|
|
|
@ -2186,12 +2192,12 @@ def upload():
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
copyfile(meta.file_path, saved_filename)
|
|
|
|
copyfile(meta.file_path, saved_filename)
|
|
|
|
except OSError, e:
|
|
|
|
except OSError as e:
|
|
|
|
flash(_(u"Failed to store file %s (Permission denied)." % saved_filename), category="error")
|
|
|
|
flash(_(u"Failed to store file %s (Permission denied)." % saved_filename), category="error")
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
os.unlink(meta.file_path)
|
|
|
|
os.unlink(meta.file_path)
|
|
|
|
except OSError, e:
|
|
|
|
except OSError as e:
|
|
|
|
flash(_(u"Failed to delete file %s (Permission denied)." % meta.file_path), category="warning")
|
|
|
|
flash(_(u"Failed to delete file %s (Permission denied)." % meta.file_path), category="warning")
|
|
|
|
|
|
|
|
|
|
|
|
file_size = os.path.getsize(saved_filename)
|
|
|
|
file_size = os.path.getsize(saved_filename)
|
|
|
@ -2223,7 +2229,7 @@ def upload():
|
|
|
|
db.session.add(db_language)
|
|
|
|
db.session.add(db_language)
|
|
|
|
# combine path and normalize path from windows systems
|
|
|
|
# combine path and normalize path from windows systems
|
|
|
|
path = os.path.join(author_dir, title_dir).replace('\\','/')
|
|
|
|
path = os.path.join(author_dir, title_dir).replace('\\','/')
|
|
|
|
db_book = db.Books(title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 01, 01), 1,
|
|
|
|
db_book = db.Books(title, "", db_author.sort, datetime.datetime.now(), datetime.datetime(101, 1, 1), 1,
|
|
|
|
datetime.datetime.now(), path, has_cover, db_author, [], db_language)
|
|
|
|
datetime.datetime.now(), path, has_cover, db_author, [], db_language)
|
|
|
|
db_book.authors.append(db_author)
|
|
|
|
db_book.authors.append(db_author)
|
|
|
|
if db_language is not None:
|
|
|
|
if db_language is not None:
|
|
|
|