mirror of
https://github.com/janeczku/calibre-web
synced 2024-11-28 20:39:59 +00:00
Added names for jobs to make log more readable
Bugfix logging delete thumbnail
This commit is contained in:
parent
ec53570118
commit
c0d0660986
@ -30,15 +30,15 @@ def get_scheduled_tasks(reconnect=True):
|
||||
|
||||
# Reconnect Calibre database (metadata.db)
|
||||
if reconnect:
|
||||
tasks.append(lambda: TaskReconnectDatabase())
|
||||
tasks.append([lambda: TaskReconnectDatabase(), 'reconnect'])
|
||||
|
||||
# Generate all missing book cover thumbnails
|
||||
if config.schedule_generate_book_covers:
|
||||
tasks.append(lambda: TaskGenerateCoverThumbnails())
|
||||
tasks.append([lambda: TaskGenerateCoverThumbnails(), 'generate book covers'])
|
||||
|
||||
# Generate all missing series thumbnails
|
||||
if config.schedule_generate_series_covers:
|
||||
tasks.append(lambda: TaskGenerateSeriesThumbnails())
|
||||
tasks.append([lambda: TaskGenerateSeriesThumbnails(), 'generate book covers'])
|
||||
|
||||
return tasks
|
||||
|
||||
@ -63,7 +63,7 @@ def register_scheduled_tasks():
|
||||
# Register scheduled tasks
|
||||
if start != end:
|
||||
scheduler.schedule_tasks(tasks=get_scheduled_tasks(), trigger='cron', hour=start)
|
||||
scheduler.schedule(func=end_scheduled_tasks, trigger='cron', hour=end)
|
||||
scheduler.schedule(func=end_scheduled_tasks, trigger='cron', name="end scheduled task", hour=end)
|
||||
|
||||
# Kick-off tasks, if they should currently be running
|
||||
if should_task_be_running(start, end):
|
||||
|
@ -47,37 +47,37 @@ class BackgroundScheduler:
|
||||
|
||||
return cls._instance
|
||||
|
||||
def schedule(self, func, trigger, **trigger_args):
|
||||
def schedule(self, func, trigger, name=None, **trigger_args):
|
||||
if use_APScheduler:
|
||||
return self.scheduler.add_job(func=func, trigger=trigger, **trigger_args)
|
||||
return self.scheduler.add_job(func=func, trigger=trigger, name=name, **trigger_args)
|
||||
|
||||
# Expects a lambda expression for the task
|
||||
def schedule_task(self, task, user=None, trigger='cron', **trigger_args):
|
||||
def schedule_task(self, task, user=None, name=None, trigger='cron', **trigger_args):
|
||||
if use_APScheduler:
|
||||
def scheduled_task():
|
||||
worker_task = task()
|
||||
worker_task.scheduled = True
|
||||
WorkerThread.add(user, worker_task)
|
||||
return self.schedule(func=scheduled_task, trigger=trigger, **trigger_args)
|
||||
return self.schedule(func=scheduled_task, trigger=trigger, name=name, **trigger_args)
|
||||
|
||||
# Expects a list of lambda expressions for the tasks
|
||||
def schedule_tasks(self, tasks, user=None, trigger='cron', **trigger_args):
|
||||
if use_APScheduler:
|
||||
for task in tasks:
|
||||
self.schedule_task(task, user=user, trigger=trigger, **trigger_args)
|
||||
self.schedule_task(task[0], user=user, trigger=trigger, name=task[1], **trigger_args)
|
||||
|
||||
# Expects a lambda expression for the task
|
||||
def schedule_task_immediately(self, task, user=None):
|
||||
def schedule_task_immediately(self, task, user=None, name=None):
|
||||
if use_APScheduler:
|
||||
def immediate_task():
|
||||
WorkerThread.add(user, task())
|
||||
return self.schedule(func=immediate_task, trigger='date')
|
||||
return self.schedule(func=immediate_task, trigger='date', name=name)
|
||||
|
||||
# Expects a list of lambda expressions for the tasks
|
||||
def schedule_tasks_immediately(self, tasks, user=None):
|
||||
if use_APScheduler:
|
||||
for task in tasks:
|
||||
self.schedule_task_immediately(task, user)
|
||||
self.schedule_task_immediately(task[0], user, name="immediately " + task[1])
|
||||
|
||||
# Remove all jobs
|
||||
def remove_all_jobs(self):
|
||||
|
@ -487,7 +487,10 @@ class TaskClearCoverThumbnailCache(CalibreTask):
|
||||
return 'ThumbnailsClear'
|
||||
|
||||
def __str__(self):
|
||||
return "Delete Thumbnail cache directory"
|
||||
if self.book_id > 0:
|
||||
return "Delete Thumbnail cache for book " + str(self.book_id)
|
||||
else:
|
||||
return "Delete Thumbnail cache directory"
|
||||
|
||||
@property
|
||||
def is_cancellable(self):
|
||||
|
Loading…
Reference in New Issue
Block a user