From ff2516e219b5eff574e2ba12c13aff1d9033814c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20David?= Date: Wed, 18 Jan 2023 16:47:53 +0100 Subject: [PATCH 1/3] Feature: Keep synced hero representations up-to-date. Fix #4331 --- .../plugins/publish/integrate_hero_version.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/openpype/plugins/publish/integrate_hero_version.py b/openpype/plugins/publish/integrate_hero_version.py index 5f4d284740..c162c83976 100644 --- a/openpype/plugins/publish/integrate_hero_version.py +++ b/openpype/plugins/publish/integrate_hero_version.py @@ -386,6 +386,25 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin): repre["_id"] = old_repre["_id"] update_data = prepare_representation_update_data( old_repre, repre) + + # Keep previously synchronized sites up-to-date + # by comparing old and new sites and adding old sites + # if missing in new ones + old_repre_files_sites = [ + f.get("sites", []) for f in old_repre.get("files", []) + ] + for i, file in enumerate(repre.get("files", [])): + repre_sites_names = { + s["name"] for s in file.get("sites", []) + } + for site in old_repre_files_sites[i]: + if site["name"] not in repre_sites_names: + # Pop the date to tag for sync + site.pop("created_dt") + file["sites"].append(site) + + update_data["files"][i] = file + op_session.update_entity( project_name, old_repre["type"], From 5476217f6ed17b44cf4fdd02849429ef10774c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20David?= Date: Wed, 18 Jan 2023 16:59:53 +0100 Subject: [PATCH 2/3] linting --- openpype/plugins/publish/integrate_hero_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/integrate_hero_version.py b/openpype/plugins/publish/integrate_hero_version.py index c162c83976..427256c137 100644 --- a/openpype/plugins/publish/integrate_hero_version.py +++ b/openpype/plugins/publish/integrate_hero_version.py @@ -404,7 +404,7 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin): file["sites"].append(site) update_data["files"][i] = file - + op_session.update_entity( project_name, old_repre["type"], From 7787ee26992ad805a957656f8ca8555349789ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20David?= Date: Wed, 25 Jan 2023 13:09:34 +0100 Subject: [PATCH 3/3] fix pop created_dt --- openpype/plugins/publish/integrate_hero_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/integrate_hero_version.py b/openpype/plugins/publish/integrate_hero_version.py index 427256c137..1a4f4bacfd 100644 --- a/openpype/plugins/publish/integrate_hero_version.py +++ b/openpype/plugins/publish/integrate_hero_version.py @@ -400,7 +400,7 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin): for site in old_repre_files_sites[i]: if site["name"] not in repre_sites_names: # Pop the date to tag for sync - site.pop("created_dt") + site.pop("created_dt", None) file["sites"].append(site) update_data["files"][i] = file