From 94cecfe36c18ac90b257192364ac387f8e6ef127 Mon Sep 17 00:00:00 2001 From: MahanthLBS Date: Thu, 9 Jul 2026 17:39:24 +0530 Subject: [PATCH] fix: sitesync dirmap and anatomy root overrides for WFH local sites --- client/ayon_core/host/dirmap.py | 53 +++++++++++++++++--- client/ayon_core/pipeline/anatomy/anatomy.py | 20 ++++++-- client/ayon_core/version.py | 2 +- package.py | 2 +- pyproject.toml | 2 +- 5 files changed, 65 insertions(+), 14 deletions(-) diff --git a/client/ayon_core/host/dirmap.py b/client/ayon_core/host/dirmap.py index 3f02be6614d..fa083bdaf01 100644 --- a/client/ayon_core/host/dirmap.py +++ b/client/ayon_core/host/dirmap.py @@ -189,10 +189,38 @@ def _get_local_sync_dirmap(self): # won't be root on cloud or sftp provider so fallback to studio if remote_provider != "local_drive": remote_site = "studio" + + # SiteSync stores roots as a list of + # {name, windows, linux, darwin}; normalize to a dict keyed by + # root name so lookups work + remote_roots = sync_settings["sites"][remote_site]["root"] + if isinstance(remote_roots, list): + remote_roots = { + root_item["name"]: root_item + for root_item in remote_roots + } + + # roots without local override in Site Settings cannot be + # remapped - make that visible instead of silently skipping + missing_root_names = [ + root_name + for root_name in remote_roots + if root_name not in active_roots_overrides + ] + if missing_root_names: + self.log.warning( + "Local root overrides are not set for roots '{}' in" + " Site Settings, paths with these roots won't be" + " remapped.".format("', '".join(missing_root_names)) + ) + for root_name, active_site_dir in active_roots_overrides.items(): + if not active_site_dir: + continue + remote_site_dir = ( remote_roots_overrides.get(root_name) - or sync_settings["sites"][remote_site]["root"][root_name] + or remote_roots.get(root_name) ) if isinstance(remote_site_dir, dict): @@ -201,14 +229,23 @@ def _get_local_sync_dirmap(self): if not remote_site_dir: continue - if os.path.isdir(active_site_dir): - if "destination_path" not in mapping: - mapping["destination_path"] = [] - mapping["destination_path"].append(active_site_dir) + if not os.path.isdir(active_site_dir): + # sync creates the folder on first download - map the + # root anyway so scene paths point where files will be + self.log.warning( + "Local folder '{}' for root '{}' does not exist" + " yet, mapping it anyway.".format( + active_site_dir, root_name + ) + ) + + if "destination_path" not in mapping: + mapping["destination_path"] = [] + mapping["destination_path"].append(active_site_dir) - if "source_path" not in mapping: - mapping["source_path"] = [] - mapping["source_path"].append(remote_site_dir) + if "source_path" not in mapping: + mapping["source_path"] = [] + mapping["source_path"].append(remote_site_dir) self.log.debug("local sync mapping:: {}".format(mapping)) return mapping diff --git a/client/ayon_core/pipeline/anatomy/anatomy.py b/client/ayon_core/pipeline/anatomy/anatomy.py index b436a24bdd5..093a63f9aac 100644 --- a/client/ayon_core/pipeline/anatomy/anatomy.py +++ b/client/ayon_core/pipeline/anatomy/anatomy.py @@ -519,8 +519,22 @@ def _get_site_root_overrides(cls, project_name, site_name): ) else: # Ask sync server to get roots overrides - roots_overrides = sitesync_addon.get_site_root_overrides( - project_name, site_name - ) + # - sitesync raises ValueError for sites other than + # 'studio'/'local'/machine site id (e.g. user picked a + # cloud site as active site) - fall back to no overrides + # instead of breaking Anatomy completely + try: + roots_overrides = sitesync_addon.get_site_root_overrides( + project_name, site_name + ) + except ValueError: + log.warning( + "Failed to receive root overrides for site '{}'" + " of project '{}', using no overrides.".format( + site_name, project_name + ), + exc_info=True + ) + roots_overrides = {} site_cache.update_data(roots_overrides) return site_cache.get_data() diff --git a/client/ayon_core/version.py b/client/ayon_core/version.py index 54572f2a5c5..6558773d9c9 100644 --- a/client/ayon_core/version.py +++ b/client/ayon_core/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring AYON addon 'core' version.""" -__version__ = "1.9.7+dev" +__version__ = "1.9.7+lbs.3" diff --git a/package.py b/package.py index 6b5df3bb887..0ba03f666dd 100644 --- a/package.py +++ b/package.py @@ -1,6 +1,6 @@ name = "core" title = "Core" -version = "1.9.7+dev" +version = "1.9.7+lbs.3" client_dir = "ayon_core" diff --git a/pyproject.toml b/pyproject.toml index bf42147c86f..c32cefa4d51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ [project] name = "ayon-core" -version = "1.9.7+dev" +version = "1.9.7+lbs.3" description = "AYON core provides the base building blocks for all other AYON addons and integrations and is responsible for discovery and initialization of other addons." authors = [ {name = "Ynput s.r.o.", email = "info@ynput.io"}