Skip to content

Commit

Permalink
fix(profile sync): force copy if sync_mode is overwirte (#555)
Browse files Browse the repository at this point in the history
closes #531 

related #519

When `sync_mode` was `overwirte` we were still making merge to get new
values for .ini.

Now in `overwrite` mode, a copy is done.
  • Loading branch information
jmkerloch authored Sep 6, 2024
2 parents 0e4e6d1 + 3b9ff5a commit a9ad61d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 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,8 @@ def sync_overwrite_local_profiles(
copy_function=copy2,
dirs_exist_ok=True,
)

# Environment variable will be converted during merge
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 a9ad61d

Please sign in to comment.