Merge pull request #4343 from Tilix4/ft_keep_hero_repres_uptodate

Feature: Keep synced hero representations up-to-date.
This commit is contained in:
Petr Kalis 2023-02-10 19:07:32 +01:00 committed by GitHub
commit 042fd998fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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", None)
file["sites"].append(site)
update_data["files"][i] = file
op_session.update_entity(
project_name,
old_repre["type"],