Backups: use constants for file names
This commit is contained in:
@@ -39,6 +39,13 @@ TELEGRAM_BOT_TOKEN = config.get("telegram", "TELEGRAM_BOT_TOKEN")
|
|||||||
TELEGRAM_CHAT_ID = config.get("telegram", "TELEGRAM_CHAT_ID")
|
TELEGRAM_CHAT_ID = config.get("telegram", "TELEGRAM_CHAT_ID")
|
||||||
NOTIFICATIONS_NAME = config.get("telegram", "NOTIFICATIONS_NAME")
|
NOTIFICATIONS_NAME = config.get("telegram", "NOTIFICATIONS_NAME")
|
||||||
|
|
||||||
|
# File name to store directories and files to back up
|
||||||
|
BACKUP_TARGETS_FILE = "backup-targets"
|
||||||
|
|
||||||
|
# Default directory fo backups (relative to app dir)
|
||||||
|
# Used when backup-targets file not exists
|
||||||
|
BACKUP_DEFAULT_DIR = "backups"
|
||||||
|
|
||||||
|
|
||||||
class BackupManager:
|
class BackupManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -146,7 +153,7 @@ class BackupManager:
|
|||||||
|
|
||||||
for app_dir_str, _ in app_dirs:
|
for app_dir_str, _ in app_dirs:
|
||||||
app_dir = Path(app_dir_str)
|
app_dir = Path(app_dir_str)
|
||||||
targets_file = app_dir / "backup-targets"
|
targets_file = app_dir / BACKUP_TARGETS_FILE
|
||||||
resolved_targets: List[Path] = []
|
resolved_targets: List[Path] = []
|
||||||
|
|
||||||
if targets_file.exists():
|
if targets_file.exists():
|
||||||
@@ -167,7 +174,7 @@ class BackupManager:
|
|||||||
self.warnings.append(warning_msg)
|
self.warnings.append(warning_msg)
|
||||||
else:
|
else:
|
||||||
# Fallback to default backups directory when no list is provided.
|
# Fallback to default backups directory when no list is provided.
|
||||||
default_target = (app_dir / "backups").resolve()
|
default_target = (app_dir / BACKUP_DEFAULT_DIR).resolve()
|
||||||
if default_target.exists():
|
if default_target.exists():
|
||||||
resolved_targets.append(default_target)
|
resolved_targets.append(default_target)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user