diff --git a/cps/admin.py b/cps/admin.py
index 1319c42a..91b34eba 100644
--- a/cps/admin.py
+++ b/cps/admin.py
@@ -44,7 +44,7 @@ from . import constants, logger, helper, services, cli
from . import db, calibre_db, ub, web_server, get_locale, config, updater_thread, babel, gdriveutils, \
kobo_sync_status, schedule
from .helper import check_valid_domain, send_test_mail, reset_password, generate_password_hash, check_email, \
- valid_email, check_username
+ valid_email, check_username, update_thumbnail_cache
from .gdriveutils import is_gdrive_ready, gdrive_support
from .render_template import render_title_template, get_sidebar_config
from .services.worker import WorkerThread
@@ -169,6 +169,17 @@ def reconnect():
abort(404)
+@admi.route("/ajax/updateThumbnails", methods=['POST'])
+@admin_required
+@login_required
+def update_thumbnails():
+ content = config.get_scheduled_task_settings()
+ if content['schedule_generate_book_covers']:
+ log.info("Update of Cover cache requested")
+ update_thumbnail_cache()
+ return ""
+
+
@admi.route("/admin/view")
@login_required
@admin_required
@@ -612,6 +623,8 @@ def load_dialogtexts(element_id):
texts["main"] = _('Are you sure you want to change shelf sync behavior for the selected user(s)?')
elif element_id == "db_submit":
texts["main"] = _('Are you sure you want to change Calibre library location?')
+ elif element_id == "admin_refresh_cover_cache":
+ texts["main"] = _('Calibre-Web will search for updated Covers and update Cover Thumbnails, this may take a while?')
elif element_id == "btnfullsync":
texts["main"] = _("Are you sure you want delete Calibre-Web's sync database "
"to force a full sync with your Kobo Reader?")
diff --git a/cps/helper.py b/cps/helper.py
index 5c532dba..d97d6475 100644
--- a/cps/helper.py
+++ b/cps/helper.py
@@ -1091,3 +1091,7 @@ def delete_thumbnail_cache():
def add_book_to_thumbnail_cache(book_id):
WorkerThread.add(None, TaskGenerateCoverThumbnails(book_id), hidden=True)
+
+
+def update_thumbnail_cache():
+ WorkerThread.add(None, TaskGenerateCoverThumbnails())
diff --git a/cps/schedule.py b/cps/schedule.py
index 1da52d6f..a051bd5f 100644
--- a/cps/schedule.py
+++ b/cps/schedule.py
@@ -30,16 +30,16 @@ def get_scheduled_tasks(reconnect=True):
# Reconnect Calibre database (metadata.db)
if reconnect:
- tasks.append([lambda: TaskReconnectDatabase(), 'reconnect'])
+ tasks.append([lambda: TaskReconnectDatabase(), 'reconnect', False])
# Generate all missing book cover thumbnails
if config.schedule_generate_book_covers:
- tasks.append([lambda: TaskGenerateCoverThumbnails(), 'generate book covers'])
- tasks.append([lambda: TaskClearCoverThumbnailCache(0), 'delete superfluous book covers'])
+ tasks.append([lambda: TaskGenerateCoverThumbnails(), 'generate book covers', False])
+ tasks.append([lambda: TaskClearCoverThumbnailCache(0), 'delete superfluous book covers', True])
# Generate all missing series thumbnails
if config.schedule_generate_series_covers:
- tasks.append([lambda: TaskGenerateSeriesThumbnails(), 'generate book covers'])
+ tasks.append([lambda: TaskGenerateSeriesThumbnails(), 'generate book covers', False])
return tasks
@@ -86,4 +86,4 @@ def register_startup_tasks():
def should_task_be_running(start, end):
now = datetime.datetime.now().hour
- return (start < end and start <= now < end) or (end < start <= now or now < end)
+ return (start < end and start <= now < end) or (end < start and (now < end or start <= now ))
diff --git a/cps/services/background_scheduler.py b/cps/services/background_scheduler.py
index eee5b7cd..27285fd9 100644
--- a/cps/services/background_scheduler.py
+++ b/cps/services/background_scheduler.py
@@ -52,32 +52,32 @@ class BackgroundScheduler:
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, name=None, trigger='cron', **trigger_args):
+ def schedule_task(self, task, user=None, name=None, hidden=False, trigger='cron', **trigger_args):
if use_APScheduler:
def scheduled_task():
worker_task = task()
worker_task.scheduled = True
- WorkerThread.add(user, worker_task)
+ WorkerThread.add(user, worker_task, hidden=hidden)
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[0], user=user, trigger=trigger, name=task[1], **trigger_args)
+ self.schedule_task(task[0], user=user, trigger=trigger, name=task[1], hidden=task[2], **trigger_args)
# Expects a lambda expression for the task
- def schedule_task_immediately(self, task, user=None, name=None):
+ def schedule_task_immediately(self, task, user=None, name=None, hidden=False):
if use_APScheduler:
def immediate_task():
- WorkerThread.add(user, task())
+ WorkerThread.add(user, task(), hidden)
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[0], user, name="immediately " + task[1])
+ self.schedule_task_immediately(task[0], user, name="immediately " + task[1], hidden=task[2])
# Remove all jobs
def remove_all_jobs(self):
diff --git a/cps/static/js/main.js b/cps/static/js/main.js
index 91084f06..04d47d6b 100755
--- a/cps/static/js/main.js
+++ b/cps/static/js/main.js
@@ -474,6 +474,17 @@ $(function() {
}
});
});
+ $("#admin_refresh_cover_cache").click(function() {
+ confirmDialog("admin_refresh_cover_cache", "GeneralChangeModal", 0, function () {
+ $.ajax({
+ method:"post",
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+ url: getPath() + "/ajax/updateThumbnails",
+ });
+ });
+ });
+
$("#restart_database").click(function() {
$("#DialogHeader").addClass("hidden");
$("#DialogFinished").addClass("hidden");
diff --git a/cps/static/js/table.js b/cps/static/js/table.js
index e04c7562..548ca8c4 100644
--- a/cps/static/js/table.js
+++ b/cps/static/js/table.js
@@ -550,7 +550,7 @@ $(function() {
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === "denied_column_value") {
- ConfirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle);
+ confirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle);
}
});
diff --git a/cps/templates/admin.html b/cps/templates/admin.html
index efbd4c6c..8b0bbc45 100644
--- a/cps/templates/admin.html
+++ b/cps/templates/admin.html
@@ -184,6 +184,9 @@
{{_('Edit Scheduled Tasks Settings')}}
+ {% if config.schedule_generate_book_covers %}
+ {{_('Refresh Thumbnail Cover Cache')}}
+ {% endif %}
@@ -279,3 +282,6 @@
{% endblock %}
+{% block modal %}
+{{ change_confirm_modal() }}
+{% endblock %}