Make MVLog state writes permission-safe
This commit is contained in:
parent
d45a15ac7b
commit
2c8a997044
1 changed files with 7 additions and 1 deletions
|
|
@ -95,8 +95,14 @@ def read_state(host: str, job_dir: str) -> dict:
|
||||||
|
|
||||||
def write_state(host: str, job_dir: str, state: dict) -> None:
|
def write_state(host: str, job_dir: str, state: dict) -> None:
|
||||||
path = f"{job_dir}/{STATE_NAME}"
|
path = f"{job_dir}/{STATE_NAME}"
|
||||||
|
tmp_path = f"{path}.tmp.$$"
|
||||||
data = json.dumps(state, ensure_ascii=False, indent=2) + "\n"
|
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:
|
def copy_job_from_remote(host: str, job_dir: str, local_input: Path) -> None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue