Commit 6f217f2e authored by 郭阔's avatar 郭阔

fix(panel): /edit 404 on macOS — systemd timer path guard

edit_source checked news-harvester@<name>.timer existence (Linux layout);
on macOS schedules are LaunchAgents plists so the edit page always 404ed.
Use pl.schedule_state/schedule_times (platform layer) for the guard and
current time instead.
parent f3100907
...@@ -863,13 +863,12 @@ def add_source(): ...@@ -863,13 +863,12 @@ def add_source():
def edit_source(name): def edit_source(name):
if not re.match(r"^[a-zA-Z0-9_-]+$", name): if not re.match(r"^[a-zA-Z0-9_-]+$", name):
abort(404) abort(404)
timer_path = SYSTEMD_DIR / f"news-harvester@{name}.timer" # 平台无关:macOS 调度是 LaunchAgents plist,旧代码检查 systemd timer 路径导致永远 404
if not timer_path.exists(): if pl.schedule_state(name) == "none":
abort(404) abort(404)
if request.method == "GET": if request.method == "GET":
timer_name = f"news-harvester@{name}.timer" current_time = ",".join(t for t in pl.schedule_times(name).split(",") if t.strip()) or "-"
current_time = read_oncalendar_from_systemd(timer_name) or parse_timer_file(timer_path)
conf = read_conf(name) conf = read_conf(name)
return render_template("edit.html", name=name, current_time=current_time, conf=conf, return render_template("edit.html", name=name, current_time=current_time, conf=conf,
providers=get_providers()) providers=get_providers())
...@@ -884,8 +883,7 @@ def edit_source(name): ...@@ -884,8 +883,7 @@ def edit_source(name):
if not valid_run_times(time): if not valid_run_times(time):
flash("时间格式应为 HH:MM,多个时间用逗号分隔", "error") flash("时间格式应为 HH:MM,多个时间用逗号分隔", "error")
timer_name = f"news-harvester@{name}.timer" current_time = ",".join(t for t in pl.schedule_times(name).split(",") if t.strip()) or "-"
current_time = read_oncalendar_from_systemd(timer_name) or parse_timer_file(timer_path)
conf = read_conf(name) conf = read_conf(name)
return render_template("edit.html", name=name, current_time=current_time, conf=conf, return render_template("edit.html", name=name, current_time=current_time, conf=conf,
providers=get_providers()) providers=get_providers())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment