@@ -164,21 +164,26 @@ def http_download(url, message=None, checksum=None, hash_alg='sha1', dl_size=Non
164
164
165
165
progress .update (percent , prog_message )
166
166
167
- if checksum and calc_checksum .hexdigest () != checksum :
168
- progress .close ()
169
- req .close ()
170
- log (4 , 'Download failed, checksums do not match!' )
171
- return False
172
-
173
- if dl_size and stat_file (dl_path ).st_size () != dl_size :
174
- progress .close ()
175
- req .close ()
176
- free_space = sizeof_fmt (diskspace ())
177
- log (4 , 'Download failed, filesize does not match! Filesystem full? Remaining diskspace in temp: {}.' .format (free_space ))
178
- return False
179
-
180
167
progress .close ()
181
168
req .close ()
169
+
170
+ checksum_ok = (not checksum or calc_checksum .hexdigest () == checksum )
171
+ size_ok = (not dl_size or stat_file (dl_path ).st_size () == dl_size )
172
+
173
+ if not all ((checksum_ok , size_ok )):
174
+ free_space = sizeof_fmt (diskspace ())
175
+ log (4 , 'Something may be wrong with the downloaded file.' )
176
+ if not checksum_ok :
177
+ log (4 , 'Provided checksum: {}\n Calculated checksum: {}' .format (checksum , calc_checksum .hexdigest ()))
178
+ if not size_ok :
179
+ free_space = sizeof_fmt (diskspace ())
180
+ log (4 , 'Expected filesize: {}\n Real filesize: {}\n Remaining diskspace: {}' .format (dl_size , stat_file (dl_path ).st_size (), free_space ))
181
+
182
+ if yesno_dialog (localize (30003 ), localize (30070 , filename = filename )): # file maybe broken. Continue anyway?
183
+ log (4 , 'Continuing despite possibly corrupt file!' )
184
+ else :
185
+ return False
186
+
182
187
store ('download_path' , dl_path )
183
188
return True
184
189
0 commit comments