summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-12-19 17:46:26 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-12-19 17:46:26 +0100
commita799c28d059f48ec93d72c515e4ecbff3b3b8b71 (patch)
treeac927e947920de781fb74215b04c155ba137c988 /module/network
parentfixed chunk size calculation (diff)
downloadpyload-a799c28d059f48ec93d72c515e4ecbff3b3b8b71.tar.xz
calc fixes
Diffstat (limited to 'module/network')
-rw-r--r--module/network/HTTPChunk.py4
-rw-r--r--module/network/HTTPDownload.py9
2 files changed, 8 insertions, 5 deletions
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index 6f9454c56..f9ad3def7 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -78,7 +78,7 @@ class HTTPChunk(HTTPBase):
break
count = self.bufferSize
if self.noRangeHeader:
- count = min(count, self.range[1]-self.range[0] - self.arrived+count)
+ count = min(count, self.range[1] - self.arrived)
if self.bucket:
count = self.bucket.add(count)
if count == 0:
@@ -98,7 +98,7 @@ class HTTPChunk(HTTPBase):
self.speedCalcTime = inttime()
self.speedCalcLen = 0
size = len(data)
- if self.arrived+size == self.range[1]-self.range[0]:
+ if self.noRangeHeader and self.arrived+size == self.range[1]:
running = False
self.speedCalcLen += size
self.arrived += size
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 4bba7724e..fbec872fa 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -135,8 +135,11 @@ class HTTPDownload():
@property
def arrived(self):
arrived = 0
- for i in range(self.info.getCount()):
- arrived += getsize(self.info.getChunkName(i)) #ugly, but difficult to calc otherwise due chunk resume
+ try:
+ for i in range(self.info.getCount()):
+ arrived += getsize(self.info.getChunkName(i)) #ugly, but difficult to calc otherwise due chunk resume
+ except OSError:
+ arrived = self.size
return arrived
def abort(self):
@@ -284,7 +287,7 @@ if __name__ == "__main__":
print "starting"
dwnld = HTTPDownload(url, "test_100mb.bin")
- d = dwnld.download(chunks=2, resume=True)
+ d = dwnld.download(chunks=5, resume=True)
d.addCallback(callb)
d.addErrback(err)