Skip to content

Commit f7e6aae

Browse files
conftest: fix rmtree cleanup crash on Linux (os.lchflags does not exist)
The archiver fixture's rmtree onerror handler called os.lchflags(path, 0) when has_lchflags was True. But has_lchflags is also True on Linux (flags are cleared via ioctl there), where os.lchflags does not exist, raising an uncaught AttributeError and turning teardown into an ERROR. Use borg's cross-platform platform.set_flags instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent be131f2 commit f7e6aae

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/borg/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
setup_logging()
1616

1717
from borg.archiver import Archiver # noqa: E402
18+
from borg.platform import set_flags # noqa: E402
1819
from borg.testsuite import has_lchflags, has_llfuse, has_pyfuse3, has_mfusepy # noqa: E402
1920
from borg.testsuite import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported # noqa: E402
2021
from borg.testsuite.archiver import BORG_EXES
@@ -197,8 +198,10 @@ def archiver(tmp_path, set_env_variables):
197198
def maybe_clear_flags_and_retry(func, path, _exc_info):
198199
if has_lchflags:
199200
# Clear any BSD flags (e.g. UF_APPEND) that may have prevented removal, then retry once.
201+
# Note: use borg's cross-platform set_flags, not os.lchflags - the latter does not exist
202+
# on Linux even though has_lchflags is True there (Linux clears flags via ioctl).
200203
try:
201-
os.lchflags(path, 0)
204+
set_flags(path, 0)
202205
func(path)
203206
except OSError:
204207
pass

0 commit comments

Comments
 (0)