`shutil.copytree` fails on bcachefs case insensitive directories
未關閉
還沒有人認領這個 Issue。
stdlib
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
On bcachefs create case insensitive directory with some file inside:
mkdir ncs
chattr +F ncs
touch ncs/something.txt
then do this
import shutil
shutil.copytree("ncs/", "target/")
fails with
Traceback (most recent call last):
File "<string>", line 1, in <module>
import shutil; shutil.copytree("ncs/", "target/")
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.14/shutil.py", line 654, in copytree
return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
ignore=ignore, copy_function=copy_function,
ignore_dangling_symlinks=ignore_dangling_symlinks,
dirs_exist_ok=dirs_exist_ok)
File "/usr/lib/python3.14/shutil.py", line 608, in _copytree
raise Error(errors)
shutil.Error: [('ncs/', 'target/', "[Errno 39] Directory not empty: 'target/'")]
This is because of
listxattr("ncs/", "bcachefs.casefold\0bcachefs_effec"..., 256) = 46
getxattr("ncs/", "bcachefs.casefold", "1", 128) = 1
setxattr("target/", "bcachefs.casefold", "1", 1, 0) = -1 ENOTEMPTY (Directory not empty)
getcwd("/home/user/_x", 1024) = 14
happening after contents were copied and case insensitivity can't be enabled afterwards.
Note: On ext4 copytree results in a directory without casefolding flag.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-145869
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先查看連結的 PR gh-145869,然後從 shutil.py 中的 shutil.copytree 和 _copytree 開始。使用報告中的命令和 Python 範例重現 case-insensitive bcachefs 失敗;當報告中的複製操作能正確處理檔案系統屬性,且不會引發所示的 Directory not empty 錯誤時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- operating-systems
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100