# HG changeset patch # User neko259 # Date 2017-01-18 16:15:12 # Node ID 3c5ca02bc54ed5f0909c634e77c4ef0f84d47019 # Parent 10b12be19c848aa496ff45a262a264076710f172 Do not run validation on files while performing sync diff --git a/boards/models/attachment/downloaders.py b/boards/models/attachment/downloaders.py --- a/boards/models/attachment/downloaders.py +++ b/boards/models/attachment/downloaders.py @@ -30,15 +30,15 @@ class Downloader: return True @staticmethod - def download(url: str): + def download(url: str, validate): # Verify content headers response_head = requests.head(url, verify=False) content_type = response_head.headers[HEADER_CONTENT_TYPE].split(';')[0] - if content_type in TYPE_URL_ONLY: + if validate and content_type in TYPE_URL_ONLY: return None length_header = response_head.headers.get(HEADER_CONTENT_LENGTH) - if length_header: + if validate and length_header: length = int(length_header) validate_file_size(length) # Get the actual content into memory @@ -63,7 +63,7 @@ class Downloader: class YouTubeDownloader(Downloader): @staticmethod - def download(url: str): + def download(url: str, validate): yt = YouTube() yt.from_url(url) videos = yt.filter(YOUTUBE_VIDEO_FORMAT) @@ -82,7 +82,7 @@ class NothingDownloader(Downloader): return REGEX_MAGNET.match(url) @staticmethod - def download(url: str): + def download(url: str, validate): return None @@ -93,9 +93,9 @@ DOWNLOADERS = ( ) -def download(url): +def download(url, validate=True): for downloader in DOWNLOADERS: if downloader.handles(url): - return downloader.download(url) + return downloader.download(url, validate=validate) raise Exception('No downloader supports this URL.') 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 @@ -236,7 +236,7 @@ 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) + attached_file = download(hostname + url, validate=False) if attached_file is None: raise SyncException(EXCEPTION_DOWNLOAD)