- fix keepalive (#218268)
parent
8aa336bc0a
commit
2c17adaf7b
@ -0,0 +1,24 @@
|
||||
--- urlgrabber/grabber.py 22 Sep 2006 00:58:05 -0000 1.48
|
||||
+++ urlgrabber/grabber.py 5 Dec 2006 23:48:51 -0000
|
||||
@@ -1198,13 +1198,21 @@
|
||||
"""dump the file to self.filename."""
|
||||
if self.append: new_fo = open(self.filename, 'ab')
|
||||
else: new_fo = open(self.filename, 'wb')
|
||||
+ try:
|
||||
+ # if we have a known range, only try to read that much.
|
||||
+ (low, high) = self.opts.range
|
||||
+ amount = high - low
|
||||
+ except TypeError, ValueError:
|
||||
+ amount = None
|
||||
bs = 1024*8
|
||||
size = 0
|
||||
|
||||
+ if amount is not None: bs = min(bs, amount - size)
|
||||
block = self.read(bs)
|
||||
size = size + len(block)
|
||||
while block:
|
||||
new_fo.write(block)
|
||||
+ if amount is not None: bs = min(bs, amount - size)
|
||||
block = self.read(bs)
|
||||
size = size + len(block)
|
||||
|
Loading…
Reference in new issue