diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-09-24 20:22:49 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-09-24 20:22:49 +0200 |
commit | 10c16952d50122c08aed9f9c7adf349826da4938 (patch) | |
tree | 4bbe4cbd46eb6b31e8e3e90717e7272539c5bfde /module/network/HTTPDownload.py | |
parent | plugins: czshare premium, czshare/quickshare/filefactory folders (diff) | |
download | pyload-10c16952d50122c08aed9f9c7adf349826da4938.tar.xz |
improved speed for high bandwith connections
Diffstat (limited to 'module/network/HTTPDownload.py')
-rw-r--r-- | module/network/HTTPDownload.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py index ac3252f68..f616b16b5 100644 --- a/module/network/HTTPDownload.py +++ b/module/network/HTTPDownload.py @@ -33,6 +33,7 @@ from module.utils import save_join class HTTPDownload(): """ loads a url http + ftp """ + def __init__(self, url, filename, get={}, post={}, referer=None, cj=None, bucket=None, options={}, progressNotify=None, disposition=False): self.url = url @@ -69,7 +70,7 @@ class HTTPDownload(): self.lastArrived = [] self.speeds = [] self.lastSpeeds = [0, 0] - + self.progressNotify = progressNotify @property @@ -93,7 +94,8 @@ class HTTPDownload(): fo = open(init, "rb+") #first chunkfile for i in range(1, self.info.getCount()): #input file - fo.seek(self.info.getChunkRange(i - 1)[1] + 1) #seek to beginning of chunk, to get rid of overlapping chunks + fo.seek( + self.info.getChunkRange(i - 1)[1] + 1) #seek to beginning of chunk, to get rid of overlapping chunks fname = "%s.chunk%d" % (self.filename, i) fi = open(fname, "rb") buf = 32 * 1024 @@ -113,7 +115,7 @@ class HTTPDownload(): if self.nameDisposition and self.disposition: self.filename = save_join(dirname(self.filename), self.nameDisposition) - + move(init, self.filename) self.info.remove() #remove info file @@ -164,7 +166,7 @@ class HTTPDownload(): chunksCreated = False done = False if self.info.getCount() > 1: # This is a resume, if we were chunked originally assume still can - self.chunkSupport=True + self.chunkSupport = True while 1: #need to create chunks @@ -177,7 +179,7 @@ class HTTPDownload(): chunks = self.info.getCount() - init.range = self.info.getChunkRange(0) + init.setRange(self.info.getChunkRange(0)) for i in range(1, chunks): c = HTTPChunk(i, self, self.info.getChunkRange(i), resume) @@ -191,10 +193,8 @@ class HTTPDownload(): self.log.debug("Invalid curl handle -> closed") c.close() - chunksCreated = True - while 1: ret, num_handles = self.m.perform() if ret != pycurl.E_CALL_MULTI_PERFORM: @@ -215,7 +215,7 @@ class HTTPDownload(): #@TODO KeyBoardInterrupts are seen as finished chunks, #but normally not handled to this process, only in the testcase - + chunksDone.add(curl) if not num_q: lastFinishCheck = t @@ -243,7 +243,7 @@ class HTTPDownload(): if self.abort: raise Abort() - sleep(0.003) #supress busy waiting - limits dl speed to (1 / x) * buffersize + #sleep(0.003) #supress busy waiting - limits dl speed to (1 / x) * buffersize self.m.select(1) failed = False @@ -261,11 +261,11 @@ class HTTPDownload(): if failed: raise BadHeader(failed) self._copyChunks() - + def updateProgress(self): if self.progressNotify: self.progressNotify(self.percent) - + def close(self): """ cleanup """ for chunk in self.chunks: |