Skip to content

Commit 035b12d

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 4838480 commit 035b12d

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
@@ -14,6 +14,7 @@
1414
setup_logging()
1515

1616
from borg.archiver import Archiver # noqa: E402
17+
from borg.platform import set_flags # noqa: E402
1718
from borg.testsuite import has_lchflags, has_llfuse, has_pyfuse3, has_mfusepy # noqa: E402
1819
from borg.testsuite import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported # noqa: E402
1920
from borg.testsuite.archiver import BORG_EXES
@@ -195,8 +196,10 @@ def archiver(tmp_path, set_env_variables):
195196
def maybe_clear_flags_and_retry(func, path, _exc_info):
196197
if has_lchflags:
197198
# Clear any BSD flags (e.g. UF_APPEND) that may have prevented removal, then retry once.
199+
# Note: use borg's cross-platform set_flags, not os.lchflags - the latter does not exist
200+
# on Linux even though has_lchflags is True there (Linux clears flags via ioctl).
198201
try:
199-
os.lchflags(path, 0)
202+
set_flags(path, 0)
200203
func(path)
201204
except OSError:
202205
pass

0 commit comments

Comments
 (0)