Skip to content

ClientGenerator::generate_to is not atomic #1406

Description

@kpp

fs::write(out_path, code).with_context(|| {
format!("Failed to write generated client to {}", out_path.display())
})?;

fs::write(out_path, code) is non-atomic. If the process is interrupted (SIGKILL/OOM/Ctrl-C) mid-write, out_path is left truncated/empty, silently corrupting a committed generated client.

Fix: write to a temp file and fs::rename into place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions