2021-03-20 10:32:50 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
# Copyright (C) 2020 mmonkey
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2022-04-24 16:40:50 +00:00
|
|
|
from flask_babel import lazy_gettext as N_
|
2021-03-20 10:32:50 +00:00
|
|
|
|
2024-07-20 16:14:54 +00:00
|
|
|
from cps import config, logger, db, ub
|
2021-03-20 10:32:50 +00:00
|
|
|
from cps.services.worker import CalibreTask
|
|
|
|
|
|
|
|
|
|
|
|
class TaskReconnectDatabase(CalibreTask):
|
2022-04-24 16:40:50 +00:00
|
|
|
def __init__(self, task_message=N_('Reconnecting Calibre database')):
|
2021-03-20 10:32:50 +00:00
|
|
|
super(TaskReconnectDatabase, self).__init__(task_message)
|
|
|
|
self.log = logger.create()
|
2024-07-20 16:14:54 +00:00
|
|
|
self.calibre_db = db.CalibreDB(expire_on_commit=False, init=True)
|
2021-03-20 10:32:50 +00:00
|
|
|
|
|
|
|
def run(self, worker_thread):
|
2024-07-20 16:14:54 +00:00
|
|
|
self.calibre_db.reconnect_db(config, ub.app_DB_path)
|
|
|
|
self.calibre_db.session.close()
|
|
|
|
self._handleSuccess()
|
2021-03-20 10:32:50 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def name(self):
|
|
|
|
return "Reconnect Database"
|
2021-09-29 07:40:12 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def is_cancellable(self):
|
|
|
|
return False
|