From b37fc98f2ea385faf6b71f773ca2eae28bc0cf07 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sun, 30 Aug 2015 12:31:23 +0200 Subject: [PATCH 1/1] winfreed.py: check if Content-Length is available before downloading --- winfreed.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/winfreed.py b/winfreed.py index 0492028..a9af707 100755 --- a/winfreed.py +++ b/winfreed.py @@ -108,6 +108,10 @@ def download_file(src_url, dest_dir): sys.stderr.write("Warning: %s exists!\n" % destfile) return + if 'Content-Length' not in response.info(): + sys.stderr.write("Cannot get the size of the file at %s\n" % src_url) + return + total_size = response.info().getheader('Content-Length').strip() total_size = int(total_size) -- 2.1.4