From d28a2abe07fe5e2ce452540c0c3bc7f566b2828c Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sat, 1 Sep 2012 12:20:19 +0200 Subject: [PATCH] fix incorrect range response issue --- you_get/common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/you_get/common.py b/you_get/common.py index 3d1447ce..44e5210a 100644 --- a/you_get/common.py +++ b/you_get/common.py @@ -161,7 +161,10 @@ def url_save(url, filepath, bar, refer = None, is_part = False): headers['Referer'] = refer response = request.urlopen(request.Request(url, headers = headers), None) - assert file_size == received + int(response.headers['content-length']) + + if file_size != received + int(response.headers['content-length']): + received = 0 + open_mode = 'wb' with open(temp_filepath, open_mode) as output: while True: