Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Atomic append fails to create a missing file

オープン 初心者向け
#201 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@harbinresearcher がすでに取り組んでいます。

2026年10月14日 から。

  • #202 @harbinresearcher による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

_write_file_atomic から始めてください。append=True の場合、一時ファイルを作成する前に、移動先が無条件で読み込まれます。issue にある再現手順を、atomic=True を指定し、親ディレクトリとファイルが存在しない状態で実行し、その後 atomic=False の経路と比較してください。完了条件は、アトミックな追記で存在しないファイルが作成されること、2 回目の追記で以前の内容が保持されること、そして既存のテストがすべて通ることです。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

write_file(path, content, append=True, atomic=True) raises OSError: Invalid file path when the destination does not exist. The same call with atomic=False creates the file, consistent with append mode.

Reproduce
from pathlib import Path
from tempfile import TemporaryDirectory

import fsutil

with TemporaryDirectory() as directory:
    path = str(Path(directory) / "new" / "file.txt")
    fsutil.write_file(path, content="first", append=True, atomic=True)

Reproduced with Python 3.12.14 on Windows and python-fsutil 0.18.0 source at d3a77c552346dc72a081284a6fd017ecc1ba234f. No mocked filesystem or injected failure is required. This was found during a code review, rather than reported from a production application.

Expected behavior

Create the missing file, as non-atomic append does. A subsequent append should preserve its previous content.

Cause and scope

_write_file_atomic reads the destination unconditionally when append=True, before creating a temporary file. Reading a missing destination raises immediately.

This differs from #194: it does not concern errors after replacement or the Windows-specific FileNotFoundError cleanup handler. Those paths can remain unchanged.

AI assistance was used to investigate the source and prepare reproduction and tests. A focused fix is ready.

主要言語
Python
スター
268
フォーク
19
平均マージ
8日 13時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fabiocaccamo/python-fsutil のほかの issue

fabiocaccamo/python-fsutil の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。