fix(data_dir): remove dot files everywhere

This commit is contained in:
2026-04-20 10:06:48 +02:00
parent 978b799ee8
commit fc7d3cb0e8
3 changed files with 16 additions and 4 deletions
+3 -2
View File
@@ -70,12 +70,13 @@ class DataDir:
shutil.rmtree(target_path) shutil.rmtree(target_path)
self.logger.debug("Deleted %s", target_path) self.logger.debug("Deleted %s", target_path)
tar_file.extractall(target_path, filter="data") tar_file.extractall(target_path, filter="data")
for target_file in target_path.iterdir(): for target_file in target_path.rglob("*"):
if re.match(r"^\..*", target_file.name): # remove dot files if target_file.name.startswith("."): # remove dot files
if target_file.is_dir(): if target_file.is_dir():
shutil.rmtree(target_file) shutil.rmtree(target_file)
else: else:
target_file.unlink() target_file.unlink()
self.logger.debug("Removed %s", target_file)
self.logger.debug("Extracted tar to %s", target_path) self.logger.debug("Extracted tar to %s", target_path)
def remove(self, path: str) -> None: def remove(self, path: str) -> None:
+1 -1
View File
@@ -26,7 +26,7 @@ class BaseTestCase(unittest.TestCase):
self.tmp_path = pathlib.Path(self.tmp_dir.name) self.tmp_path = pathlib.Path(self.tmp_dir.name)
return self.tmp_dir.name return self.tmp_dir.name
def mock(self, spec: type | None = None) -> unittest.mock.Mock: def new_mock(self, spec: type | None = None) -> unittest.mock.Mock:
mock = unittest.mock.Mock(spec) mock = unittest.mock.Mock(spec)
self.mocks += [mock] self.mocks += [mock]
return mock return mock
+12 -1
View File
@@ -97,10 +97,21 @@ class TestDataDir(BaseTestCase):
def test_extract_tar_bytes_create_without_dotfiles(self) -> None: def test_extract_tar_bytes_create_without_dotfiles(self) -> None:
tar_bytes = self.__get_tar_bytes( tar_bytes = self.__get_tar_bytes(
{"value": "value", ".value": "value", ".git/test": "test"} {
"value": "value",
".value": "value",
".git/test": "test",
"dir/.invalid": "value",
"dir/.test/hello": "value",
}
) )
self.data_dir.extract_tar_bytes("test_1", tar_bytes) self.data_dir.extract_tar_bytes("test_1", tar_bytes)
self.assert_file_content(self.tmp_path / "test_1" / "value", "value") self.assert_file_content(self.tmp_path / "test_1" / "value", "value")
assert not (self.tmp_path / "test_1" / ".value").exists()
assert not (self.tmp_path / "test_1" / ".git").exists()
assert (self.tmp_path / "test_1" / "dir").exists()
assert not (self.tmp_path / "test_1" / "dir" / ".invalid").exists()
assert not (self.tmp_path / "test_1" / "dir" / ".test").exists()
def test_extract_tar_bytes_update(self) -> None: def test_extract_tar_bytes_update(self) -> None:
self.__create_path( self.__create_path(