From 7831bef0506f963b506a8f2c505277589c7ac6cc Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 5 May 2021 15:59:00 -0400 Subject: [PATCH] Don't fail the sync completely when a remote file does not exist. --- crc/api/workflow_sync.py | 9 ++++++--- crc/services/workflow_sync.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crc/api/workflow_sync.py b/crc/api/workflow_sync.py index 3204e936..54c5e8c6 100644 --- a/crc/api/workflow_sync.py +++ b/crc/api/workflow_sync.py @@ -184,9 +184,12 @@ def update_or_create_current_file(remote,workflow_spec_id,updatefile): currentfile.content_type = updatefile['content_type'] currentfile.primary_process_id = updatefile['primary_process_id'] session.add(currentfile) - content = WorkflowSyncService.get_remote_file_by_hash(remote, updatefile['md5_hash']) - FileService.update_file(currentfile, content, updatefile['type']) - + try: + content = WorkflowSyncService.get_remote_file_by_hash(remote, updatefile['md5_hash']) + FileService.update_file(currentfile, content, updatefile['type']) + except ApiError: + # Remote files doesn't exist, don't update it. + print("Remote file " + currentfile.name + " does not exist, so not syncing.") def sync_changed_files(remote,workflow_spec_id): """ diff --git a/crc/services/workflow_sync.py b/crc/services/workflow_sync.py index 849c815e..2c16cf5f 100644 --- a/crc/services/workflow_sync.py +++ b/crc/services/workflow_sync.py @@ -47,6 +47,6 @@ class WorkflowSyncService(object): return json.loads(response.text) else: raise ApiError("workflow_sync_error", - "Received an invalid response from the protocol builder (status %s): %s when calling " + "Received an invalid response from the remote CR-Connect API (status %s): %s when calling " "url '%s'." % (response.status_code, response.text, url))