Sophie

Sophie

distrib > Arklinux > devel > i586 > by-pkgid > e775d2cef85c2ac234cd31d8346fceab > files > 3

python-urlgrabber-3.0.0-3ark.src.rpm

--- 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)