`shutil.copytree` fails on bcachefs case insensitive directories
未关闭
还没有人认领这个 Issue。
stdlib
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- 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