You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
876 B
25 lines
876 B
--- 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)
|
|
|