mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-10 23:15:37 +08:00
Various task creation fixes
This commit is contained in:
parent
3fd89f3eca
commit
adcf54a366
2 changed files with 11 additions and 3 deletions
|
@ -2280,15 +2280,19 @@ Google Cloud storage: GOOGLE_PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS\n\
|
|||
type = "housekeeping"
|
||||
else:
|
||||
type = "backup"
|
||||
if event == "create_backup_interval_task":
|
||||
interval = values["scheduled_task_interval"]
|
||||
else:
|
||||
interval = None
|
||||
result = create_scheduled_task(
|
||||
config_file=config_file,
|
||||
type=type,
|
||||
interval_minutes=values["scheduled_task_interval"],
|
||||
interval_minutes=interval,
|
||||
hour=values["scheduled_task_hour"],
|
||||
minute=values["scheduled_task_minute"],
|
||||
)
|
||||
if result:
|
||||
sg.Popup(_t("config_gui.scheduled_task_creation_success"))
|
||||
sg.Popup(_t("config_gui.scheduled_task_creation_success"), keep_on_top=True)
|
||||
else:
|
||||
sg.PopupError(
|
||||
_t("config_gui.scheduled_task_creation_failure"),
|
||||
|
|
|
@ -115,11 +115,15 @@ def create_scheduled_task_unix(
|
|||
crontab_file = []
|
||||
|
||||
try:
|
||||
replaced = False
|
||||
with open(cron_file, "r", encoding="utf-8") as file_handle:
|
||||
current_crontab = file_handle.readlines()
|
||||
for line in current_crontab:
|
||||
if "--{type}" in line:
|
||||
if f"--{type}" in line:
|
||||
logger.info(f"Replacing existing {type} task")
|
||||
if replaced:
|
||||
logger.info(f"Skipping duplicate {type} task")
|
||||
continue
|
||||
crontab_file.append(crontab_entry)
|
||||
replaced = True
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue