Fix update download on some platforms with broken ssl

This commit is contained in:
HelloZeroNet 2016-03-16 22:07:42 +01:00
parent 69d919d3c4
commit 9a57b5a01d

View file

@ -12,16 +12,13 @@ monkey.patch_all()
def update(): def update():
# Gevent https bug workaround (https://github.com/gevent/gevent/issues/477) from src.util import helper
reload(socket)
reload(httplib)
reload(ssl)
print "Downloading.", print "Downloading.",
file = urllib.urlopen("https://github.com/HelloZeroNet/ZeroNet/archive/master.zip") req = helper.httpRequest("https://github.com/HelloZeroNet/ZeroNet/archive/master.zip")
data = StringIO.StringIO() data = StringIO.StringIO()
while True: while True:
buff = file.read(1024 * 16) buff = req.read(1024 * 16)
if not buff: if not buff:
break break
data.write(buff) data.write(buff)
@ -40,7 +37,12 @@ def update():
print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled
print "Extracting...", print "Extracting...",
try:
zip = zipfile.ZipFile(data) zip = zipfile.ZipFile(data)
except Exception, err:
data.seek(0)
print "Unpack error", err, data.read()
return False
for inner_path in zip.namelist(): for inner_path in zip.namelist():
if ".." in inner_path: if ".." in inner_path:
continue continue
@ -73,6 +75,7 @@ def update():
print dest_path, err print dest_path, err
print "Done." print "Done."
return True
if __name__ == "__main__": if __name__ == "__main__":