diff --git a/openpype/modules/sync_server/providers/gdrive.py b/openpype/modules/sync_server/providers/gdrive.py index 4e24fe41d2..7d22138123 100644 --- a/openpype/modules/sync_server/providers/gdrive.py +++ b/openpype/modules/sync_server/providers/gdrive.py @@ -328,9 +328,12 @@ class GDriveHandler(AbstractProvider): last_tick = status = response = None status_val = 0 while response is None: - if server.is_representation_paused(representation['_id'], - check_parents=True, - project_name=project_name): + if server.is_representation_paused( + project_name, + representation['_id'], + site, + check_parents=True + ): raise ValueError("Paused during process, please redo.") if status: status_val = float(status.progress()) @@ -415,9 +418,12 @@ class GDriveHandler(AbstractProvider): last_tick = status = response = None status_val = 0 while response is None: - if server.is_representation_paused(representation['_id'], - check_parents=True, - project_name=project_name): + if server.is_representation_paused( + project_name, + representation['_id'], + site, + check_parents=True + ): raise ValueError("Paused during process, please redo.") if status: status_val = float(status.progress()) diff --git a/openpype/modules/sync_server/sync_server.py b/openpype/modules/sync_server/sync_server.py index 85b0774e90..aef3623efa 100644 --- a/openpype/modules/sync_server/sync_server.py +++ b/openpype/modules/sync_server/sync_server.py @@ -284,9 +284,6 @@ class SyncServerThread(threading.Thread): # building folder tree structure in memory # call only if needed, eg. DO_UPLOAD or DO_DOWNLOAD for sync in sync_repres: - if self.module.\ - is_representation_paused(sync['_id']): - continue if limit <= 0: continue files = sync.get("files") or [] diff --git a/openpype/modules/sync_server/sync_server_module.py b/openpype/modules/sync_server/sync_server_module.py index 68a5346e20..93b8fef821 100644 --- a/openpype/modules/sync_server/sync_server_module.py +++ b/openpype/modules/sync_server/sync_server_module.py @@ -500,27 +500,41 @@ class SyncServerModule(OpenPypeModule, ITrayModule): self.reset_site_on_representation(project_name, representation_id, site_name=site_name, pause=False) - def is_representation_paused(self, representation_id, - check_parents=False, project_name=None): + def is_representation_paused(self, project_name, representation_id, + site_name, check_parents=False): """ - Returns if 'representation_id' is paused or not. + Returns if 'representation_id' is paused or not for site. Args: - representation_id (string): MongoDB objectId value + project_name (str): project to check if paused + representation_id (str): MongoDB objectId value + site (str): site to check representation is paused for check_parents (bool): check if parent project or server itself are not paused - project_name (string): project to check if paused - if 'check_parents', 'project_name' should be set too Returns: (bool) """ - condition = representation_id in self._paused_representations - if check_parents and project_name: - condition = condition or \ - self.is_project_paused(project_name) or \ - self.is_paused() - return condition + representation = get_representation_by_id(project_name, + representation_id, + fields=["files.sites"]) + if not representation: + return False + + # Check parents are paused + if check_parents and (self.is_project_paused(project_name) or \ + self.is_paused()): + return True + + # Check if representation is paused + for file_info in representation.get("files", []): + for site in file_info.get("sites", []): + if site["name"] != site_name: + continue + + return site.get("paused", False) + + return False def pause_project(self, project_name): """