Deleting of non exisiting folders gives no internal error anymore re-inserting title sort function during upload earlier
This commit is contained in:
parent
8d406117ce
commit
694620790c
|
@ -299,12 +299,16 @@ def delete_book_file(book, calibrepath):
|
||||||
# check that path is 2 elements deep, check that target path has no subfolders
|
# check that path is 2 elements deep, check that target path has no subfolders
|
||||||
if book.path.count('/') == 1:
|
if book.path.count('/') == 1:
|
||||||
path = os.path.join(calibrepath, book.path)
|
path = os.path.join(calibrepath, book.path)
|
||||||
if len(next(os.walk(path))[1]):
|
if os.path.isdir(path):
|
||||||
web.app.logger.error(
|
if len(next(os.walk(path))[1]):
|
||||||
"Deleting book " + str(book.id) + " failed, path has subfolders: " + book.path)
|
web.app.logger.error(
|
||||||
|
"Deleting book " + str(book.id) + " failed, path has subfolders: " + book.path)
|
||||||
|
return False
|
||||||
|
shutil.rmtree(path, ignore_errors=True)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
web.app.logger.error("Deleting book " + str(book.id) + " failed, book path not valid: " + book.path)
|
||||||
return False
|
return False
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
web.app.logger.error("Deleting book " + str(book.id) + " failed, book path value: "+ book.path)
|
web.app.logger.error("Deleting book " + str(book.id) + " failed, book path value: "+ book.path)
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -3311,7 +3311,7 @@ def upload():
|
||||||
db.session.add(db.Comments(upload_comment, book_id))
|
db.session.add(db.Comments(upload_comment, book_id))
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort)
|
||||||
|
|
||||||
book = db.session.query(db.Books) \
|
book = db.session.query(db.Books) \
|
||||||
.filter(db.Books.id == book_id).filter(common_filters()).first()
|
.filter(db.Books.id == book_id).filter(common_filters()).first()
|
||||||
|
@ -3331,7 +3331,7 @@ def upload():
|
||||||
for author in db_book.authors:
|
for author in db_book.authors:
|
||||||
author_names.append(author.name)
|
author_names.append(author.name)
|
||||||
if len(request.files.getlist("btn-upload")) < 2:
|
if len(request.files.getlist("btn-upload")) < 2:
|
||||||
db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort)
|
# db.session.connection().connection.connection.create_function("title_sort", 1, db.title_sort)
|
||||||
cc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()
|
cc = db.session.query(db.Custom_Columns).filter(db.Custom_Columns.datatype.notin_(db.cc_exceptions)).all()
|
||||||
if current_user.role_edit() or current_user.role_admin():
|
if current_user.role_edit() or current_user.role_admin():
|
||||||
return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc,title=_(u"edit metadata"))
|
return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc,title=_(u"edit metadata"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user