diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-17 22:14:48 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-17 22:14:48 +0200 |
commit | 7094105fb06be18b9aa3154d99f92441b085212c (patch) | |
tree | 60ccd61f505cd7e3c749fbfe69407dc0ed763094 | |
parent | not working restart method (diff) | |
download | pyload-7094105fb06be18b9aa3154d99f92441b085212c.tar.xz |
fixes unnormal pycurl behaviour
-rw-r--r-- | module/network/HTTPChunk.py | 4 | ||||
-rw-r--r-- | module/network/HTTPDownload.py | 24 | ||||
-rw-r--r-- | module/plugins/hooks/UnRar.py | 3 |
3 files changed, 18 insertions, 13 deletions
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py index ee143330e..fc2310715 100644 --- a/module/network/HTTPChunk.py +++ b/module/network/HTTPChunk.py @@ -232,8 +232,8 @@ class HTTPChunk(HTTPRequest): """parse data from recieved header""" for orgline in self.decodeResponse(self.header).splitlines(): line = orgline.strip().lower() - if line.startswith("accept-ranges") and "bytes" in line: - self.p.chunkSupport = True +# if line.startswith("accept-ranges") and "bytes" in line: +# self.p.chunkSupport = True if line.startswith("content-disposition") and "filename=" in line: name = orgline.partition("filename=")[2] diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py index 781929b9d..b5f6313d5 100644 --- a/module/network/HTTPDownload.py +++ b/module/network/HTTPDownload.py @@ -63,7 +63,6 @@ class HTTPDownload(): self.m = pycurl.CurlMulti() #needed for speed calculation - self.lastChecked = 0 self.lastArrived = [] self.speeds = [] self.lastSpeeds = [0, 0] @@ -148,7 +147,9 @@ class HTTPDownload(): self.chunks.append(init) self.m.add_handle(init.getHandle()) - chunksDone = 0 + lastFinishCheck = 0 + lastTimeCheck = 0 + chunksDone = set() chunksCreated = False if self.info.getCount() > 1: # This is a resume, if we were chunked originally assume still can self.chunkSupport=True @@ -186,10 +187,13 @@ class HTTPDownload(): if ret != pycurl.E_CALL_MULTI_PERFORM: break - while 1: + t = time() + + # reduce these calls + while lastFinishCheck + 1 < t: num_q, ok_list, err_list = self.m.info_read() for c in ok_list: - chunksDone += 1 + chunksDone.add(c) for c in err_list: curl, errno, msg = c #test if chunk was finished, otherwise raise the exception @@ -199,24 +203,24 @@ class HTTPDownload(): #@TODO KeyBoardInterrupts are seen as finished chunks, #but normally not handled to this process, only in the testcase - chunksDone += 1 + chunksDone.add(c[0]) if not num_q: + lastFinishCheck = t break - if chunksDone == len(self.chunks): + if len(chunksDone) == len(self.chunks): break #all chunks loaded # calc speed once per second - t = time() - if self.lastChecked + 1 < t: + if lastTimeCheck + 1 < t: diff = [c.arrived - (self.lastArrived[i] if len(self.lastArrived) > i else 0) for i, c in enumerate(self.chunks)] self.lastSpeeds[1] = self.lastSpeeds[0] self.lastSpeeds[0] = self.speeds - self.speeds = [float(a) / (t - self.lastChecked) for a in diff] + self.speeds = [float(a) / (t - lastTimeCheck) for a in diff] self.lastArrived = [c.arrived for c in self.chunks] - self.lastChecked = t + lastTimeCheck = t self.updateProgress() if self.abort: diff --git a/module/plugins/hooks/UnRar.py b/module/plugins/hooks/UnRar.py index 94ae9da11..d5dfa1998 100644 --- a/module/plugins/hooks/UnRar.py +++ b/module/plugins/hooks/UnRar.py @@ -21,7 +21,7 @@ from __future__ import with_statement import sys import os from os.path import exists, join, isabs, isdir -from os import remove, makedirs, rmdir, listdir, chown, chmod +from os import remove, makedirs, rmdir, listdir, chmod from traceback import print_exc from module.plugins.Hook import Hook @@ -31,6 +31,7 @@ from module.utils import save_join if os.name != "nt": from pwd import getpwnam + from os import chown import re |