Make MVLog state writes permission-safe

This commit is contained in:
hbrain 2026-05-25 20:15:28 +00:00
parent d45a15ac7b
commit 2c8a997044

View file

@ -95,8 +95,14 @@ def read_state(host: str, job_dir: str) -> dict:
def write_state(host: str, job_dir: str, state: dict) -> None:
path = f"{job_dir}/{STATE_NAME}"
tmp_path = f"{path}.tmp.$$"
data = json.dumps(state, ensure_ascii=False, indent=2) + "\n"
ssh(host, f"cat > {remote_q(path)}", input_text=data)
cmd = (
f"cat > {remote_q(tmp_path)} && "
f"chmod 664 {remote_q(tmp_path)} && "
f"mv {remote_q(tmp_path)} {remote_q(path)}"
)
ssh(host, cmd, input_text=data)
def copy_job_from_remote(host: str, job_dir: str, local_input: Path) -> None: