diff --git a/boards/models/post/sync.py b/boards/models/post/sync.py --- a/boards/models/post/sync.py +++ b/boards/models/post/sync.py @@ -6,6 +6,7 @@ from boards.models import KeyPair, Globa from boards.models.attachment.downloaders import download from boards.utils import get_file_mimetype, get_file_hash from django.db import transaction +from django import forms EXCEPTION_NODE = 'Sync node returned an error: {}.' EXCEPTION_DOWNLOAD = 'File was not downloaded.' @@ -236,15 +237,20 @@ class SyncManager: tag_ref = tag_refs.find("{}[@ref='{}']".format( TAG_ATTACHMENT_REF, attachment.text)) url = tag_ref.get(ATTR_URL) - attached_file = download(hostname + url) - if attached_file is None: - raise SyncException(EXCEPTION_DOWNLOAD) + try: + attached_file = download(hostname + url) + + if attached_file is None: + raise SyncException(EXCEPTION_DOWNLOAD) - hash = get_file_hash(attached_file) - if hash != attachment.text: - raise SyncException(EXCEPTION_HASH) + hash = get_file_hash(attached_file) + if hash != attachment.text: + raise SyncException(EXCEPTION_HASH) - files.append(attached_file) + files.append(attached_file) + except forms.ValidationError: + urls.append(hostname+url) + if is_old: post = global_id.post