From 9830553748a2a4a1930361b41a1076dbaa6d9f4a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 1 Aug 2012 17:41:26 -0700 Subject: [PATCH] Fix percent done on resumed /clone.bundle The Content-Length when resuming is the number of bytes that remain in the file. To compute the total size as expected by the progress meter, we must add the bytes already stored. While we are in this method fix uses of % operator to ensure a tuple is always supplied. Change-Id: Ic899231b5bc0ab43b3ddb1d29845f6390e820115 --- project.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project.py b/project.py index 68c1c687..35dbafd4 100644 --- a/project.py +++ b/project.py @@ -1564,7 +1564,7 @@ class Project(object): try: req = urllib2.Request(srcUrl) if pos > 0: - req.add_header('Range', 'bytes=%d-' % pos) + req.add_header('Range', 'bytes=%d-' % (pos,)) try: r = urllib2.urlopen(req) @@ -1583,7 +1583,7 @@ class Project(object): msg = e.read() if len(msg) > 0 and msg[-1] == '\n': msg = msg[0:-1] - msg = ' (%s)' % msg + msg = ' (%s)' % (msg,) except: msg = '' else: @@ -1601,7 +1601,7 @@ class Project(object): p = None try: - size = r.headers.get('content-length', 0) + size = pos + r.headers.get('content-length', 0) unit = 1 << 10 if size and not quiet: @@ -1611,7 +1611,7 @@ class Project(object): else: desc = 'KB' p = Progress( - 'Downloading %s' % self.relpath, + 'Downloading %s' % (self.relpath,), int(size) / unit, units=desc) if pos > 0: