From 5f3a83737c9be2f68c3cfada381c6b856469a364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 21 Mar 2016 17:43:25 +0100 Subject: [PATCH] Slight tweak --- blender_cloud/pillar.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/blender_cloud/pillar.py b/blender_cloud/pillar.py index e66ae80..67b0687 100644 --- a/blender_cloud/pillar.py +++ b/blender_cloud/pillar.py @@ -149,17 +149,14 @@ async def download_to_file(url, filename, *, try: with open(header_store, 'r') as infile: stored_headers = requests.structures.CaseInsensitiveDict(json.load(infile)) - try: - expected_content_length = int(stored_headers['Content-Length']) - statinfo = os.stat(filename) - if expected_content_length != statinfo.st_size: - log.debug('File size should be %i but is %i; ignoring cache.', - expected_content_length, statinfo.st_size) - stored_headers = {} - except (KeyError, ValueError): - pass - except IOError: - log.debug('IO error ') + + # Check file length. + expected_content_length = int(stored_headers['Content-Length']) + statinfo = os.stat(filename) + if expected_content_length != statinfo.st_size: + log.debug('File size should be %i but is %i; ignoring cache.', + expected_content_length, statinfo.st_size) + stored_headers = {} except Exception as ex: log.warning('Unable to load headers from %r, ignoring cache: %s', header_store, str(ex))