From 29731401b58a639efb2619730f659f88e8242eca Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 14 Jun 2020 20:36:47 +0200 Subject: [PATCH] add test for hardlinked CACHEDIR.TAG issue #4911 --- src/borg/testsuite/archiver.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 385803ecc..4c3c133a5 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -1279,6 +1279,20 @@ class ArchiverTestCase(ArchiverTestCaseBase): '--exclude-caches', '--keep-exclude-tags', self.repository_location + '::test') self._assert_test_keep_tagged() + @pytest.mark.skipif(not are_hardlinks_supported(), reason='hardlinks not supported') + def test_recreate_hardlinked_tags(self): # test for issue #4911 + self.cmd('init', '--encryption=none', self.repository_location) + self.create_regular_file('file1', contents=CACHE_TAG_CONTENTS) # "wrong" filename, but correct tag contents + os.mkdir(os.path.join(self.input_path, 'subdir')) # to make sure the tag is encountered *after* file1 + os.link(os.path.join(self.input_path, 'file1'), + os.path.join(self.input_path, 'subdir', CACHE_TAG_NAME)) # correct tag name, hardlink to file1 + self.cmd('create', self.repository_location + '::test', 'input') + # in the "test" archive, we now have, in this order: + # - a regular file item for "file1" + # - a hardlink item for "CACHEDIR.TAG" referring back to file1 for its contents + self.cmd('recreate', '--exclude-caches', '--keep-exclude-tags', self.repository_location + '::test') + # if issue #4911 is present, the recreate will crash with a KeyError for "input/file1" + @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='Linux capabilities test, requires fakeroot >= 1.20.2') def test_extract_capabilities(self): fchown = os.fchown