mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix backup config bug
This commit is contained in:
parent
8232a630ee
commit
37ccc447c4
@ -1,3 +1,4 @@
|
||||
from http import server
|
||||
import sys
|
||||
import logging
|
||||
import datetime
|
||||
@ -291,10 +292,10 @@ class helpers_management:
|
||||
@staticmethod
|
||||
def set_backup_config(server_id: int, backup_path: str = None, max_backups: int = None):
|
||||
logger.debug(f"Updating server {server_id} backup config with {locals()}")
|
||||
try:
|
||||
if Backups.select().where(Backups.server_id == server_id).count() != 0:
|
||||
new_row = False
|
||||
conf = {}
|
||||
except IndexError:
|
||||
else:
|
||||
conf = {
|
||||
"directories": None,
|
||||
"max_backups": 0,
|
||||
|
@ -17,6 +17,7 @@ from app.classes.models.management import management_helper
|
||||
from app.classes.controllers.users_controller import Users_Controller
|
||||
from app.classes.controllers.servers_controller import Servers_Controller
|
||||
from app.classes.models.servers import servers_helper
|
||||
from app.classes.models.users import users_helper
|
||||
|
||||
logger = logging.getLogger('apscheduler')
|
||||
|
||||
@ -373,6 +374,8 @@ class TasksManager:
|
||||
if not event.exception:
|
||||
if str(event.job_id).isnumeric():
|
||||
task = management_helper.get_scheduled_task_model(int(event.job_id))
|
||||
management_helper.add_to_audit_log_raw('system', users_helper.get_user_id_by_name('system'), task.server_id,
|
||||
f"Task with id {task.schedule_id} completed successfully", '127.0.0.1')
|
||||
if task.one_time:
|
||||
self.remove_job(task.schedule_id)
|
||||
logger.info("one time task detected. Deleting...")
|
||||
|
@ -452,6 +452,10 @@ class PanelHandler(BaseHandler):
|
||||
return
|
||||
|
||||
server = self.controller.get_server_obj(server_id)
|
||||
management_helper.add_to_audit_log_raw(
|
||||
self.controller.users.get_user_by_id(exec_user['user_id'])['username'], exec_user['user_id'], server_id,
|
||||
f"Backup now executed for server {server_id} ",
|
||||
source_ip=self.get_remote_ip())
|
||||
|
||||
server.backup_server()
|
||||
self.redirect(f"/panel/server_detail?id={server_id}&subpage=backup")
|
||||
|
Loading…
Reference in New Issue
Block a user