jafeha / parabird

Simple script written in python to build an os independent truecrypt encrypted usb-stick containing a portable thunderbird, enigmail, torbirdy and vidalia.
GNU General Public License v3.0
10 stars 7 forks source link

download_function() check downloads #16

Closed jafeha closed 11 years ago

jafeha commented 11 years ago

using the releases.mozilla.org mirror returns sometimes with a timeout creating a 4k file. we need to check if the file really gets downloaded. we probably can use the urlretrieve internal magic to do this:

Changed in version 2.5: urlretrieve() will raise ContentTooShortError when it 
detects that the amount of data available was less than the expected amount 
(which is the size reported by a Content-Length header). This can occur, for 
example, when the download is interrupted.

The Content-Length is treated as a lower bound: if there’s more data to read, 
urlretrieve() reads more data, but if less data is available, it raises the 
exception.

You can still retrieve the downloaded data in this case, it is stored in the 
content attribute of the exception instance.

If no Content-Length header was supplied, urlretrieve() can not check the size 
of the data it has downloaded, and just returns it. In this case you just have 
to assume that the download was successful.
jojoo- commented 11 years ago

do we run into a exception when we get that 4k file?

if not, then this won't work.

what's in the small file?

4k is probably the smallest file on your filesystem

jafeha commented 11 years ago

should be fixed with 93bb44b and 733bef8