From d2e48426a6ec43fcdf62a42e9ffa44f4e72e77c4 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Thu, 30 Mar 2023 19:04:44 +0200 Subject: [PATCH] add all sites of previous files to new files (#4737) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jakub Ježek --- .../plugins/publish/integrate_hero_version.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/openpype/plugins/publish/integrate_hero_version.py b/openpype/plugins/publish/integrate_hero_version.py index e796f7b376..80141e88fe 100644 --- a/openpype/plugins/publish/integrate_hero_version.py +++ b/openpype/plugins/publish/integrate_hero_version.py @@ -388,22 +388,27 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin): 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", []) + # by comparing old and new sites and adding old sites + # if missing in new ones + # Prepare all sites from all files in old representation + old_site_names = set() + for file_info in old_repre.get("files", []): + old_site_names |= { + site["name"] + for site in file_info["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", None) - file["sites"].append(site) - update_data["files"][i] = file + for file_info in update_data.get("files", []): + file_info.setdefault("sites", []) + file_info_site_names = { + site["name"] + for site in file_info["sites"] + } + for site_name in old_site_names: + if site_name not in file_info_site_names: + file_info["sites"].append({ + "name": site_name + }) op_session.update_entity( project_name,