add test for #9032

This commit is contained in:
Thomas Waldmann 2025-09-30 19:32:00 +02:00
parent 0ee5d6f018
commit b27dba670c
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -1065,3 +1065,28 @@ def test_create_with_compression_algorithms(archivers, request):
for i in range(count):
os.unlink(os.path.join(archiver.input_path, f"zeros_{i}"))
os.unlink(os.path.join(archiver.input_path, f"random_{i}"))
def test_exclude_nodump_dir_with_file(archivers, request):
"""A directory flagged NODUMP and its contents must not be archived."""
archiver = request.getfixturevalue(archivers)
if not has_lchflags:
pytest.skip("platform does not support setting UF_NODUMP")
# Prepare input tree: input/nd (NODUMP) containing a file.
ndir = os.path.join(archiver.input_path, "nd")
os.mkdir(ndir)
with open(os.path.join(ndir, "file_in_ndir"), "wb") as f:
f.write(b"hello")
# Set NODUMP flag on the directory (Linux: chattr +d, BSD: chflags nodump)
platform.set_flags(ndir, stat.UF_NODUMP)
# Create repo and archive
cmd(archiver, "repo-create", RK_ENCRYPTION)
cmd(archiver, "create", "test", "input")
# Verify: neither the directory nor its contained file are present in the archive
list_output = cmd(archiver, "list", "test", "--short")
assert "input/nd\n" not in list_output
assert "input/nd/file_in_ndir\n" not in list_output