Files
LXC-Dispatcharr-modificado-…/apps/backups/apps.py
T
root f56b088643
Base Image Build / prepare (push) Has been cancelled
Build and Push Multi-Arch Docker Image / build-and-push (push) Has been cancelled
Frontend Tests / test (push) Has been cancelled
Base Image Build / docker (amd64, ubuntu-24.04) (push) Has been cancelled
Base Image Build / docker (arm64, ubuntu-24.04-arm) (push) Has been cancelled
Base Image Build / create-manifest (push) Has been cancelled
Proyecto LCX Dispatcharr multicuenta
2026-05-09 21:24:50 +02:00

41 lines
1.4 KiB
Python

import logging
from django.apps import AppConfig
logger = logging.getLogger(__name__)
class BackupsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.backups"
verbose_name = "Backups"
def ready(self):
"""Initialize backup scheduler on app startup."""
from dispatcharr.app_initialization import should_skip_initialization
# Skip if this is a management command, worker process, or dev server
if should_skip_initialization():
return
logger.debug("Syncing backup scheduler on app startup")
self._sync_backup_scheduler()
def _sync_backup_scheduler(self):
"""Sync backup scheduler task to database."""
from core.models import CoreSettings
from .scheduler import _sync_periodic_task, DEFAULTS
try:
# Ensure settings exist with defaults if this is a new install
CoreSettings.objects.get_or_create(
key="backup_settings",
defaults={"name": "Backup Settings", "value": DEFAULTS.copy()}
)
# Always sync the periodic task (handles new installs, updates, or missing tasks)
logger.debug("Syncing backup scheduler")
_sync_periodic_task()
except Exception as e:
# Log but don't fail startup if there's an issue
logger.warning(f"Failed to initialize backup scheduler: {e}")