Skip to content

Commit

Permalink
fix(profile sync): force copy if sync_mode is overwirte
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkerloch committed Sep 5, 2024
1 parent 6e4ac79 commit 3aad5ac
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions qgis_deployment_toolbelt/jobs/job_profiles_synchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ def sync_installed_profiles_from_downloaded_profiles(
"Installed profiles are going to be overridden by downloaded ones."
)
# copy all downloaded profiles
self.sync_overwrite_local_profiles(profiles_to_copy=downloaded_profiles)
self.sync_overwrite_local_profiles(
profiles_to_copy=downloaded_profiles, overwrite=True
)

else:
logger.debug(
Expand All @@ -262,21 +264,18 @@ def sync_installed_profiles_from_downloaded_profiles(
)

def sync_overwrite_local_profiles(
self, profiles_to_copy: tuple[QdtProfile]
self, profiles_to_copy: tuple[QdtProfile], overwrite: bool = False
) -> None:
"""Overwrite local profiles with downloaded ones.
Args:
profiles_to_copy (tuple[QdtProfile]): tuple of profiles to copy
overwrite (bool): overwrite profile if it exists (default False)
"""

# copy downloaded profiles into this
for d in profiles_to_copy:
if d.path_in_qgis.exists():
logger.info(f"Merging {d.folder} to {d.path_in_qgis}")
installed_profile = QdtProfile(folder=d.path_in_qgis)
d.merge_to(installed_profile)
else:
if overwrite:
logger.info(f"Copying {d.folder} to {d.path_in_qgis}")
d.path_in_qgis.mkdir(parents=True, exist_ok=True)
copytree(
Expand All @@ -285,3 +284,7 @@ def sync_overwrite_local_profiles(
copy_function=copy2,
dirs_exist_ok=True,
)

logger.info(f"Merging {d.folder} to {d.path_in_qgis}")
installed_profile = QdtProfile(folder=d.path_in_qgis)
d.merge_to(installed_profile)

0 comments on commit 3aad5ac

Please sign in to comment.