From: Antonio Ospite Date: Sun, 30 Aug 2015 10:31:23 +0000 (+0200) Subject: winfreed.py: check if Content-Length is available before downloading X-Git-Url: https://git.ao2.it/winfreed.git/commitdiff_plain/b37fc98f2ea385faf6b71f773ca2eae28bc0cf07?hp=036da882f6f4ee1fc5a2bc0f468f9205b78df006 winfreed.py: check if Content-Length is available before downloading --- 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)