From 425dbc6db1addf6cb603d0774f5aa6abf4637a01 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Mon, 27 Oct 2025 18:07:49 +0100 Subject: [PATCH 1/4] Implemented copy of source folder thumbnail --- .../tools/push_to_project/models/integrate.py | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 2adc708cf3..8a6000122f 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -3,6 +3,7 @@ import re import copy import itertools import sys +import tempfile import traceback import uuid from typing import Optional, Any @@ -709,11 +710,14 @@ class ProjectPushItemProcess: project_entity, src_folder_type ) + new_thumbnail_id = self._get_new_folder_thumbnail_id( + project_entity, src_folder_entity) folder_entity = new_folder_entity( folder_name, dst_folder_type, parent_id=parent_id, - attribs=new_folder_attrib + attribs=new_folder_attrib, + thumbnail_id=new_thumbnail_id ) if folder_label: folder_entity["label"] = folder_label @@ -733,6 +737,36 @@ class ProjectPushItemProcess: folder_entity["path"] = "/".join([parent_path, folder_name]) return folder_entity + def _get_new_folder_thumbnail_id( + self, + project_entity: dict[str, Any], + src_folder_entity: dict[str, Any] + ) -> Optional[str]: + """Copy thumbnail possibly set on folder. + + Could be different from representation thumbnails, and it is only shown + when folder is selected. + """ + new_thumbnail_id = None + if src_folder_entity["thumbnailId"]: + thumbnail = ayon_api.get_thumbnail_by_id( + self._item.src_project_name, src_folder_entity["thumbnailId"] + ) + if not thumbnail.id: + return new_thumbnail_id + + try: + with tempfile.NamedTemporaryFile(delete=False) as tmp_file: + tmp_file.write(thumbnail.content) + temp_file_path = tmp_file.name + + new_thumbnail_id = ayon_api.create_thumbnail( + project_entity["name"], temp_file_path) + finally: + if temp_file_path and os.path.exists(temp_file_path): + os.remove(temp_file_path) + return new_thumbnail_id + def _get_dst_folder_type( self, project_entity: dict[str, Any], From 9d3585a0c0d73aae50ab2dd444fa1e0aea3bec71 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Oct 2025 15:12:38 +0100 Subject: [PATCH 2/4] Renamed method Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 8a6000122f..0968b99eb5 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -737,7 +737,7 @@ class ProjectPushItemProcess: folder_entity["path"] = "/".join([parent_path, folder_name]) return folder_entity - def _get_new_folder_thumbnail_id( + def _create_new_folder_thumbnail( self, project_entity: dict[str, Any], src_folder_entity: dict[str, Any] From 6dc68606222c88ffaac871bc25f68e5fe0856a19 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Oct 2025 15:13:35 +0100 Subject: [PATCH 3/4] Reorganized flow Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- .../tools/push_to_project/models/integrate.py | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 0968b99eb5..33eac6c3d6 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -747,24 +747,28 @@ class ProjectPushItemProcess: Could be different from representation thumbnails, and it is only shown when folder is selected. """ + if not src_folder_entity["thumbnailId"]: + return None + + thumbnail = ayon_api.get_folder_thumbnail( + self._item.src_project_name, + src_folder_entity["id"], + src_folder_entity["thumbnailId"] + ) + if not thumbnail.id: + return None + + with tempfile.NamedTemporaryFile(delete=False) as tmp_file: + tmp_file.write(thumbnail.content) + temp_file_path = tmp_file.name + new_thumbnail_id = None - if src_folder_entity["thumbnailId"]: - thumbnail = ayon_api.get_thumbnail_by_id( - self._item.src_project_name, src_folder_entity["thumbnailId"] - ) - if not thumbnail.id: - return new_thumbnail_id - - try: - with tempfile.NamedTemporaryFile(delete=False) as tmp_file: - tmp_file.write(thumbnail.content) - temp_file_path = tmp_file.name - - new_thumbnail_id = ayon_api.create_thumbnail( - project_entity["name"], temp_file_path) - finally: - if temp_file_path and os.path.exists(temp_file_path): - os.remove(temp_file_path) + try: + new_thumbnail_id = ayon_api.create_thumbnail( + project_entity["name"], temp_file_path) + finally: + if os.path.exists(temp_file_path): + os.remove(temp_file_path) return new_thumbnail_id def _get_dst_folder_type( From 35926269a624b8bbde492defa6aaf756e10c8316 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Wed, 29 Oct 2025 15:14:38 +0100 Subject: [PATCH 4/4] Used renamed method --- client/ayon_core/tools/push_to_project/models/integrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 33eac6c3d6..cacce44942 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -710,7 +710,7 @@ class ProjectPushItemProcess: project_entity, src_folder_type ) - new_thumbnail_id = self._get_new_folder_thumbnail_id( + new_thumbnail_id = self._create_new_folder_thumbnail( project_entity, src_folder_entity) folder_entity = new_folder_entity( folder_name,