Skip to content

Commit

Permalink
Merge pull request #2777 from mashehu/fix-missing-files-in-update
Browse files Browse the repository at this point in the history
move also subdirectories during update [skip changelog]
  • Loading branch information
mashehu committed Feb 20, 2024
2 parents eae4cca + 89a3154 commit ae5971d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions nf_core/components/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,31 +737,33 @@ def move_files_from_tmp_dir(self, component: str, install_folder: str, repo_path
new_version (str): The version of the module/subworkflow that was installed.
"""
temp_component_dir = Path(install_folder, component)
files = [f.name for f in temp_component_dir.iterdir() if f.is_file()]
files = [file_path for file_path in temp_component_dir.rglob("*") if file_path.is_file()]
pipeline_path = Path(self.dir, self.component_type, repo_path, component)

if pipeline_path.exists():
pipeline_files = [f.name for f in pipeline_path.iterdir() if f.is_file()]
# check if any *.config file exists in the pipeline
if any([f.endswith(".config") for f in pipeline_files]):
# move the *.config file to the temporary directory
config_files = [f for f in files if f.endswith(".config")]
for config_file in config_files:
log.debug(f"Moving '{component}/{config_file}' to updated component")
shutil.move(Path(pipeline_path, config_file), Path(temp_component_dir, config_file))
files.append(config_file)
config_files = [f for f in pipeline_files if str(f).endswith(".config")]
for config_file in config_files:
log.debug(f"Moving '{component}/{config_file}' to updated component")
shutil.move(pipeline_path / config_file, temp_component_dir / config_file)
files.append(temp_component_dir / config_file)

else:
log.debug(f"Creating new {self.component_type[:-1]} '{component}' in '{self.component_type}/{repo_path}'")

log.debug(f"Removing old version of {self.component_type[:-1]} '{component}'")
self.clear_component_dir(component, str(pipeline_path))

os.makedirs(pipeline_path)
pipeline_path.mkdir(parents=True, exist_ok=True)
for file in files:
file = file.relative_to(temp_component_dir)
path = Path(temp_component_dir, file)
if os.path.exists(path):
shutil.move(path, Path(pipeline_path, file))
if path.exists():
log.debug(f"Moving '{file}' to updated component")
dest = Path(pipeline_path, file)
dest.parent.mkdir(parents=True, exist_ok=True)
shutil.move(path, dest)

log.info(f"Updating '{repo_path}/{component}'")
log.debug(f"Updating {self.component_type[:-1]} '{component}' to {new_version} from {repo_path}")
Expand Down

0 comments on commit ae5971d

Please sign in to comment.