summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPDownload.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/network/HTTPDownload.py')
-rw-r--r--module/network/HTTPDownload.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 440a3defa..ac3252f68 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -21,6 +21,7 @@ from os import remove, fsync
from os.path import dirname
from time import sleep, time
from shutil import move
+from logging import getLogger
import pycurl
@@ -51,6 +52,8 @@ class HTTPDownload():
self.chunks = []
+ self.log = getLogger("log")
+
try:
self.info = ChunkInfo.load(filename)
self.info.resume = True #resume is only possible with valid info file
@@ -119,7 +122,6 @@ class HTTPDownload():
chunks = max(1, chunks)
resume = self.info.resume and resume
- self.chunks = []
try:
self._download(chunks, resume)
@@ -128,6 +130,13 @@ class HTTPDownload():
code = e.args[0]
if code == 33:
# try again without resume
+ self.log.debug("Errno 33 -> Restart without resume")
+
+ #remove old handles
+ for chunk in self.chunks:
+ self.m.remove_handle(chunk.c)
+ chunk.close()
+
return self._download(chunks, False)
else:
raise e
@@ -142,6 +151,8 @@ class HTTPDownload():
self.info.clear()
self.info.addChunk("%s.chunk0" % self.filename, (0, 0)) #create an initial entry
+ self.chunks = []
+
init = HTTPChunk(0, self, None, resume) #initial chunk that will load complete file (if needed)
self.chunks.append(init)
@@ -177,6 +188,7 @@ class HTTPDownload():
self.m.add_handle(handle)
else:
#close immediatly
+ self.log.debug("Invalid curl handle -> closed")
c.close()
@@ -204,7 +216,7 @@ class HTTPDownload():
#@TODO KeyBoardInterrupts are seen as finished chunks,
#but normally not handled to this process, only in the testcase
- chunksDone.add(c[0])
+ chunksDone.add(curl)
if not num_q:
lastFinishCheck = t