fix(bot-relay): sweep stale relay artifacts + never leak the deliver tempfile

Widen the DM tempfile-leak fix (#91902/#92407) to the sibling sites
PR #92784 introduced:

- tools/bot_relay.py: expose the 6h stale sweep as
  cleanup_bot_relay_artifacts() (cleanup_*_cache contract) and wire it
  into gateway housekeeping — previously it ran only when the Desktop
  drained the outbox, so plaintext envelopes/replies queued while the
  Desktop was away could sit on disk forever.
- tui_gateway/methods_bot_relay.py: move the payload write inside the
  try/finally so a failed write no longer leaks hermes-relay-dm-*.txt.
- tools/bot_mode_dm.py: _spawn_delivery takes dm_file=None for relay
  waiter deliveries, which have no plaintext DM tempfile to reclaim.
This commit is contained in:
Teknium
2026-08-23 02:57:51 -07:00
parent 793fba428a
commit 764dba6953
5 changed files with 102 additions and 4 deletions
+2 -2
View File
@@ -110,9 +110,9 @@ def _(rid, params: dict) -> dict:
return _err(rid, 4092, f"no profile '{profile}' on this gateway")
fd, tmp = tempfile.mkstemp(prefix="hermes-relay-dm-", suffix=".txt", text=True)
with os.fdopen(fd, "w", encoding="utf-8") as f:
f.write(message)
try:
with os.fdopen(fd, "w", encoding="utf-8") as f:
f.write(message)
proc = subprocess.run(
local_delivery_command(resolved, tmp),
capture_output=True,