ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(cron): match job lines exactly
Juan Denis9b813b4166a1
diff --git a/backend/app/services/cron_service.py b/backend/app/services/cron_service.pyindex e43a03f4..92e576c9 100644--- a/backend/app/services/cron_service.py+++ b/backend/app/services/cron_service.py@@ -311,10 +311,21 @@ class CronService:job_id: str) -> bool:"""Is this crontab line the given job's entry (bare or shim-wrapped,active or commented out)?"""- if not (schedule and command):+ if not (schedule and command and job_id):return False- return (f"{schedule} {command}" in line- or f"{SHIM_PATH} {job_id} -- {command}" in line)++ cleaned = line.strip()+ if cleaned.startswith('#'):+ cleaned = cleaned[1:].lstrip()+ parsed = cls._parse_cron_line(cleaned, 0)+ if not parsed or parsed['schedule'] != schedule:+ return False++ return parsed['command'] in {+ command,+ f"{SHIM_PATH} {job_id} -- {command}",+ cls._crontab_command(command, True, job_id),+ }@classmethoddef _describe_schedule(cls, schedule: str) -> str:diff --git a/backend/tests/BASELINE_COUNT b/backend/tests/BASELINE_COUNTindex d3128dda..05166d84 100644--- a/backend/tests/BASELINE_COUNT+++ b/backend/tests/BASELINE_COUNT@@ -1 +1 @@-4732+4735diff --git a/backend/tests/test_cron_crontab_join.py b/backend/tests/test_cron_crontab_join.pyindex df22dd0b..324b0a4f 100644--- a/backend/tests/test_cron_crontab_join.py+++ b/backend/tests/test_cron_crontab_join.py@@ -142,6 +142,32 @@ def test_tracked_shim_line_matches_toggle_and_remove(linux_cron):assert CMD not in linux_cron['crontab']+def test_toggle_matches_exact_command_not_command_prefix(linux_cron):+ job_id = _add()+ extended_command = f'{CMD} --different-job'+ linux_cron['crontab'] += f'{SCHEDULE} {extended_command}\n'++ assert CronService.toggle_job(job_id, False)['success']++ lines = linux_cron['crontab'].splitlines()+ assert f'# {SCHEDULE} {CMD}' in lines+ assert f'{SCHEDULE} {extended_command}' in lines+++def test_tracked_toggle_matches_exact_wrapped_command(linux_cron):+ job_id = _add()+ assert CronService.set_tracking(job_id, True)['success']+ wrapped = CronService._crontab_command(CMD, True, job_id)+ extended_command = f'{wrapped} --different-job'+ linux_cron['crontab'] += f'{SCHEDULE} {extended_command}\n'++ assert CronService.toggle_job(job_id, False)['success']++ lines = linux_cron['crontab'].splitlines()+ assert f'# {SCHEDULE} {wrapped}' in lines+ assert f'{SCHEDULE} {extended_command}' in lines++def test_foreign_crontab_lines_left_untouched(linux_cron):linux_cron['crontab'] = "MAILTO=root\n15 2 * * * /opt/other/task.sh\n"job_id = _add()