fix(cron): clean up job output dir in remove_job

remove_job() deletes the job from cron/jobs.json but leaves the per-job
output directory at ~/.hermes/cron/output/{job_id}/ behind. Over time
this accumulates orphaned dirs that never get reclaimed.

Adopted from #13510 by @hekaru-agent; the honcho RLock half of that PR
was already salvaged in commit dad021745 so this lands the remaining
cron cleanup hunk on its own.
This commit is contained in:
hekaru-agent 2026-05-08 06:20:35 -07:00 committed by Teknium
parent a3131862bd
commit f4e621f7d8

View file

@ -8,6 +8,7 @@ Output is saved to ~/.hermes/cron/output/{job_id}/{timestamp}.md
import copy
import json
import logging
import shutil
import tempfile
import threading
import os
@ -696,6 +697,10 @@ def remove_job(job_id: str) -> bool:
jobs = [j for j in jobs if j["id"] != job_id]
if len(jobs) < original_len:
save_jobs(jobs)
# Clean up output directory to prevent orphaned dirs accumulating
job_output_dir = OUTPUT_DIR / job_id
if job_output_dir.exists():
shutil.rmtree(job_output_dir)
return True
return False