Skip to content

Commit

Permalink
Improved logging of book title on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzieIsaacs committed Feb 6, 2022
1 parent 411c139 commit 0c3c0c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cps/editbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def upload_single_file(request, book, book_id):
# Queue uploader info
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book.id), escape(book.title))
uploadText=_(u"File format %(ext)s added to %(book)s", ext=file_ext.upper(), book=link)
WorkerThread.add(current_user.name, TaskUpload(uploadText))
WorkerThread.add(current_user.name, TaskUpload(uploadText), escape(book.title))

return uploader.process(
saved_filename, *os.path.splitext(requested_file.filename),
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def upload():
flash(error, category="error")
link = '<a href="{}">{}</a>'.format(url_for('web.show_book', book_id=book_id), escape(title))
uploadText = _(u"File %(file)s uploaded", file=link)
WorkerThread.add(current_user.name, TaskUpload(uploadText))
WorkerThread.add(current_user.name, TaskUpload(uploadText, escape(title)))

if len(request.files.getlist("btn-upload")) < 2:
if current_user.role_edit() or current_user.role_admin():
Expand Down
5 changes: 3 additions & 2 deletions cps/tasks/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
from cps.services.worker import CalibreTask, STAT_FINISH_SUCCESS

class TaskUpload(CalibreTask):
def __init__(self, taskMessage):
def __init__(self, taskMessage, book_title):
super(TaskUpload, self).__init__(taskMessage)
self.start_time = self.end_time = datetime.now()
self.stat = STAT_FINISH_SUCCESS
self.progress = 1
self.book_title = book_title

def run(self, worker_thread):
"""Upload task doesn't have anything to do, it's simply a way to add information to the task list"""
Expand All @@ -34,4 +35,4 @@ def name(self):
return "Upload"

def __str__(self):
return "Upload {}".format(self.message)
return "Upload {}".format(self.book_title)

0 comments on commit 0c3c0c0

Please sign in to comment.