mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 01:50:31 +00:00
Bugfix failed tasks can no longer aborted
Metdatabackup is done on startup if app mode is test
This commit is contained in:
parent
b28a2cc58c
commit
76b0411c33
@ -27,14 +27,12 @@ from .tasks.metadata_backup import TaskBackupMetadata
|
|||||||
|
|
||||||
def get_scheduled_tasks(reconnect=True):
|
def get_scheduled_tasks(reconnect=True):
|
||||||
tasks = list()
|
tasks = list()
|
||||||
# config.schedule_reconnect or
|
# Reconnect Calibre database (metadata.db) based on config.schedule_reconnect
|
||||||
# Reconnect Calibre database (metadata.db)
|
|
||||||
if reconnect:
|
if reconnect:
|
||||||
tasks.append([lambda: TaskReconnectDatabase(), 'reconnect', False])
|
tasks.append([lambda: TaskReconnectDatabase(), 'reconnect', False])
|
||||||
|
|
||||||
# ToDo make configurable. Generate metadata.opf file for each changed book
|
# ToDo make configurable. Generate metadata.opf file for each changed book
|
||||||
if False:
|
tasks.append([lambda: TaskBackupMetadata("en"), 'backup metadata', False])
|
||||||
tasks.append([lambda: TaskBackupMetadata("en"), 'backup metadata', False])
|
|
||||||
|
|
||||||
# Generate all missing book cover thumbnails
|
# Generate all missing book cover thumbnails
|
||||||
if config.schedule_generate_book_covers:
|
if config.schedule_generate_book_covers:
|
||||||
|
@ -634,7 +634,7 @@ function UserActions (value, row) {
|
|||||||
|
|
||||||
/* Function for cancelling tasks */
|
/* Function for cancelling tasks */
|
||||||
function TaskActions (value, row) {
|
function TaskActions (value, row) {
|
||||||
var cancellableStats = [0, 1, 2];
|
var cancellableStats = [0, 2];
|
||||||
if (row.task_id && row.is_cancellable && cancellableStats.includes(row.stat)) {
|
if (row.task_id && row.is_cancellable && cancellableStats.includes(row.stat)) {
|
||||||
return [
|
return [
|
||||||
"<div class=\"danger task-cancel\" data-toggle=\"modal\" data-target=\"#cancelTaskModal\" data-task-id=\"" + row.task_id + "\" title=\"Cancel\">",
|
"<div class=\"danger task-cancel\" data-toggle=\"modal\" data-target=\"#cancelTaskModal\" data-task-id=\"" + row.task_id + "\" title=\"Cancel\">",
|
||||||
|
@ -22,8 +22,8 @@ from urllib.request import urlopen
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
from html import escape
|
from html import escape
|
||||||
|
|
||||||
from cps import config, db, fs, gdriveutils, logger, ub
|
from cps import config, db, gdriveutils, logger
|
||||||
from cps.services.worker import CalibreTask, STAT_CANCELLED, STAT_ENDED
|
from cps.services.worker import CalibreTask
|
||||||
from flask_babel import lazy_gettext as N_
|
from flask_babel import lazy_gettext as N_
|
||||||
|
|
||||||
OPF_NAMESPACE = "http://www.idpf.org/2007/opf"
|
OPF_NAMESPACE = "http://www.idpf.org/2007/opf"
|
||||||
@ -74,7 +74,10 @@ class TaskBackupMetadata(CalibreTask):
|
|||||||
def backup_metadata(self):
|
def backup_metadata(self):
|
||||||
try:
|
try:
|
||||||
metadata_backup = self.calibre_db.session.query(db.Metadata_Dirtied).all()
|
metadata_backup = self.calibre_db.session.query(db.Metadata_Dirtied).all()
|
||||||
custom_columns = self.calibre_db.session.query(db.CustomColumns).order_by(db.CustomColumns.label).all()
|
custom_columns = (self.calibre_db.session.query(db.CustomColumns)
|
||||||
|
.filter(db.CustomColumns.mark_for_delete == 0)
|
||||||
|
.filter(db.CustomColumns.datatype.notin_(db.cc_exceptions))
|
||||||
|
.order_by(db.CustomColumns.label).all())
|
||||||
count = len(metadata_backup)
|
count = len(metadata_backup)
|
||||||
i = 0
|
i = 0
|
||||||
for backup in metadata_backup:
|
for backup in metadata_backup:
|
||||||
@ -226,11 +229,11 @@ class TaskBackupMetadata(CalibreTask):
|
|||||||
# doc = etree.tostring(package, xml_declaration=True, encoding='utf-8', pretty_print=True) # .replace(b"&quot;", b""")
|
# doc = etree.tostring(package, xml_declaration=True, encoding='utf-8', pretty_print=True) # .replace(b"&quot;", b""")
|
||||||
try:
|
try:
|
||||||
with open(book_metadata_filepath, 'wb') as f:
|
with open(book_metadata_filepath, 'wb') as f:
|
||||||
# f.write(doc)
|
|
||||||
doc.write(f, xml_declaration=True, encoding='utf-8', pretty_print=True)
|
doc.write(f, xml_declaration=True, encoding='utf-8', pretty_print=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
# ToDo: Folder not writeable error
|
# ToDo: Folder not writeable error
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return "Metadata backup"
|
return "Metadata backup"
|
||||||
|
@ -18,4 +18,4 @@ lxml>=3.8.0,<5.0.0
|
|||||||
flask-wtf>=0.14.2,<1.2.0
|
flask-wtf>=0.14.2,<1.2.0
|
||||||
chardet>=3.0.0,<4.1.0
|
chardet>=3.0.0,<4.1.0
|
||||||
advocate>=1.0.0,<1.1.0
|
advocate>=1.0.0,<1.1.0
|
||||||
Flask-Limiter>=2.3.0,<3.2.0
|
Flask-Limiter>=2.3.0,<3.3.0
|
||||||
|
Loading…
Reference in New Issue
Block a user