Skip to content

Commit

Permalink
Merge pull request #746 from ynput/bugfix/dirmap_for_remote_sites
Browse files Browse the repository at this point in the history
Global: dirmap for non local nor studio sites
  • Loading branch information
iLLiCiTiT committed Jul 10, 2024
2 parents 5eb3fa0 + b5c48b0 commit b487574
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions client/ayon_core/host/dirmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,23 @@ def _get_local_sync_dirmap(self):
cached=False)

# overrides for roots set in `Site Settings`
active_roots = sitesync_addon.get_site_root_overrides(
project_name, active_site)
remote_roots = sitesync_addon.get_site_root_overrides(
project_name, remote_site)
active_roots_overrides = self._get_site_root_overrides(
sitesync_addon, project_name, active_site)

self.log.debug("active roots overrides {}".format(active_roots))
self.log.debug("remote roots overrides {}".format(remote_roots))
remote_roots_overrides = self._get_site_root_overrides(
sitesync_addon, project_name, remote_site)

current_platform = platform.system().lower()
remote_provider = sitesync_addon.get_provider_for_site(
project_name, remote_site
)
# dirmap has sense only with regular disk provider, in the workfile
# won't be root on cloud or sftp provider
# won't be root on cloud or sftp provider so fallback to studio
if remote_provider != "local_drive":
remote_site = "studio"
for root_name, active_site_dir in active_roots.items():
for root_name, active_site_dir in active_roots_overrides.items():
remote_site_dir = (
remote_roots.get(root_name)
remote_roots_overrides.get(root_name)
or sync_settings["sites"][remote_site]["root"][root_name]
)

Expand All @@ -220,3 +218,22 @@ def _get_local_sync_dirmap(self):

self.log.debug("local sync mapping:: {}".format(mapping))
return mapping

def _get_site_root_overrides(
self, sitesync_addon, project_name, site_name
):
"""Safely handle root overrides.
SiteSync raises ValueError for non local or studio sites.
"""
# TODO: could be removed when `get_site_root_overrides` is not raising
# an Error but just returns {}
try:
site_roots_overrides = sitesync_addon.get_site_root_overrides(
project_name, site_name)
except ValueError:
site_roots_overrides = {}
self.log.debug("{} roots overrides {}".format(
site_name, site_roots_overrides))

return site_roots_overrides

0 comments on commit b487574

Please sign in to comment.