diff --git a/src/antares_web_installer/app.py b/src/antares_web_installer/app.py index cf6cd1e..904a1d0 100644 --- a/src/antares_web_installer/app.py +++ b/src/antares_web_installer/app.py @@ -21,7 +21,7 @@ from antares_web_installer.shortcuts import create_shortcut, get_desktop # List of files and directories to exclude during installation -EXCLUDED_FILES = { +EXCLUDED_ROOT_RESOURCES = { Path("config.yaml"), Path("archives"), Path("internal_studies"), @@ -188,13 +188,16 @@ def copy_files(self): write or if self.target_dir already exists. """ src_dir_content = list(self.source_dir.iterdir()) - src_dir_content_length = len(src_dir_content) + dirs_to_copy = [] + for root_dir in src_dir_content: + if root_dir.relative_to(self.source_dir) not in EXCLUDED_ROOT_RESOURCES: + dirs_to_copy.append(root_dir) + src_dir_content_length = len(dirs_to_copy) initial_value = self.progress - for index, elt_path in enumerate(src_dir_content): - relative_elt_path = elt_path.relative_to(self.source_dir) - if relative_elt_path not in EXCLUDED_FILES and not elt_path.name.lower().startswith("antareswebinstaller"): + for index, elt_path in enumerate(dirs_to_copy): + if not elt_path.name.lower().startswith("antareswebinstaller"): logger.info(f"Copying '{elt_path}'") try: if elt_path.is_file(): diff --git a/tests/test_app.py b/tests/test_app.py index 3017eb3..5645279 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -3,7 +3,7 @@ import pytest -from antares_web_installer.app import App, EXCLUDED_FILES +from antares_web_installer.app import App, EXCLUDED_ROOT_RESOURCES class TestApp: @@ -62,8 +62,8 @@ def test_copy_files__nominal_case(self, datadir: Path) -> None: content = file.read_bytes() old_checksum = old_checksum_by_name[relative_path] new_checksum = hashlib.md5(content).hexdigest() - root_name = relative_path.parts[0] - if root_name in EXCLUDED_FILES: + root_name = Path(relative_path.parts[0]) + if root_name in EXCLUDED_ROOT_RESOURCES: assert old_checksum == new_checksum, f"File {file} must not have been modified" else: assert old_checksum != new_checksum, f"File {file} must have been updated"