Skip to content

Atomic delete: interrupted idstack-learnings-delete can destroy the whole log #60

Description

@savvides

Surfaced by PR #35 (closed — its perf premise was synthetic and os.replace widened file mode 600→644, verified). The underlying point is real and worth doing properly.

bin/idstack-learnings-delete:42-43 truncates in place. An interrupt mid-write leaves the learnings log truncated or empty — the file is the user's accumulated project memory, so this is data loss, not an inconvenience.

Do it the way bin/idstack-manifest-merge:126-141 already does: tempfile.mkstemp in the learnings dir, shutil.copymode the original mode onto the temp before the replace (this is what #35 got wrong), os.replace, unlink on exception.

Ships with a test asserting mode is preserved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docs-debtDocumentation gaps recorded but not closed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions