Skip to content

Fix atomic append to missing files - #202

Open
harbinresearcher wants to merge 1 commit into
fabiocaccamo:mainfrom
harbinresearcher:codex/create-atomic-append-files
Open

harbinresearcher wants to merge 1 commit into
fabiocaccamo:mainfrom
harbinresearcher:codex/create-atomic-append-files

Conversation

@harbinresearcher

@harbinresearcher harbinresearcher commented Oct 14, 2026 •

Copy link
Copy Markdown

Describe your changes

Only read the previous contents during atomic append if the destination exists. This lets atomic append create a missing file, matching non-atomic append, while preserving the existing temporary-file replacement and Windows cleanup handling.

Add eight native-filesystem regression cases covering atomic/non-atomic append, UTF-8/UTF-16, empty/nonempty first writes, nested parent creation and a subsequent append. Against the unchanged source, four atomic cases fail and the four non-atomic cases pass.

Validation:

  • Windows Python 3.12.14: baseline 302 passed/3 skipped; patched 310 passed/3 skipped. Both had one pytest cache permission warning.
  • Windows Python 3.10.21: baseline 302 passed/3 skipped; patched 310 passed/3 skipped (one cache warning each).
  • Linux Python 3.12.15: baseline 305 passed; patched 313 passed.
  • Both full-suite comparisons reached 98.40% coverage (required minimum: 90%).
  • Pinned pre-commit hooks, source mypy, sdist/wheel build and installed-wheel UTF-8/UTF-16 smoke checks passed.

This does not change concurrent append guarantees or the error/cleanup behavior discussed in #194. The reproduction uses real temporary files and no fault injection. AI assistance was used for investigation, tests, implementation and review; no independent human review is claimed.

Related issue

Closes #201

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

@harbinresearcher

Copy link
Copy Markdown
Author

The Codacy check reports two Bandit B101 findings on the new pytest assertions in tests/test_io.py (lines 210 and 214): "Use of assert detected". Both are test assertions, following this module's existing pytest style; neither is a runtime security check. I have retained them rather than suppressing the rule or changing repository settings.

The full suite passes locally on Windows Python 3.10/3.12 and Linux Python 3.12. The GitHub Actions "Test package" run is currently action_required, awaiting maintainer approval to run this first fork contribution. Remote CI is therefore not yet verified.

Codacy findings: https://app.codacy.com/api/v3/analysis/organizations/gh/fabiocaccamo/repositories/python-fsutil/pull-requests/202/issues
Actions: https://github.com/fabiocaccamo/python-fsutil/actions/runs/38503952366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Atomic append fails to create a missing file

1 participant