Skip to content

Commit

Permalink
Fix update download on some platforms with broken ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Mar 16, 2016
1 parent 69d919d commit 9a57b5a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@


def update():
# Gevent https bug workaround (https://github.com/gevent/gevent/issues/477)
reload(socket)
reload(httplib)
reload(ssl)
from src.util import helper

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()
while True:
buff = file.read(1024 * 16)
buff = req.read(1024 * 16)
if not buff:
break
data.write(buff)
Expand All @@ -40,7 +37,12 @@ def update():
print "Plugins enabled:", plugins_enabled, "disabled:", plugins_disabled

print "Extracting...",
zip = zipfile.ZipFile(data)
try:
zip = zipfile.ZipFile(data)
except Exception, err:
data.seek(0)
print "Unpack error", err, data.read()
return False
for inner_path in zip.namelist():
if ".." in inner_path:
continue
Expand Down Expand Up @@ -73,6 +75,7 @@ def update():
print dest_path, err

print "Done."
return True


if __name__ == "__main__":
Expand Down

0 comments on commit 9a57b5a

Please sign in to comment.