summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2012-08-01 17:41:26 -0700
committerShawn O. Pearce <sop@google.com>2012-08-01 17:41:26 -0700
commit9830553748a2a4a1930361b41a1076dbaa6d9f4a (patch)
treec98e7b66c28c1cef5648b917b1a2311de9e61acc
parent2bc7f5cb3af981d673b44ce9a1ff5a272535def6 (diff)
downloadgit-repo-9830553748a2a4a1930361b41a1076dbaa6d9f4a.tar.gz
Fix percent done on resumed /clone.bundlev1.10.0
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
-rw-r--r--project.py8
1 files 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):
1564 try: 1564 try:
1565 req = urllib2.Request(srcUrl) 1565 req = urllib2.Request(srcUrl)
1566 if pos > 0: 1566 if pos > 0:
1567 req.add_header('Range', 'bytes=%d-' % pos) 1567 req.add_header('Range', 'bytes=%d-' % (pos,))
1568 1568
1569 try: 1569 try:
1570 r = urllib2.urlopen(req) 1570 r = urllib2.urlopen(req)
@@ -1583,7 +1583,7 @@ class Project(object):
1583 msg = e.read() 1583 msg = e.read()
1584 if len(msg) > 0 and msg[-1] == '\n': 1584 if len(msg) > 0 and msg[-1] == '\n':
1585 msg = msg[0:-1] 1585 msg = msg[0:-1]
1586 msg = ' (%s)' % msg 1586 msg = ' (%s)' % (msg,)
1587 except: 1587 except:
1588 msg = '' 1588 msg = ''
1589 else: 1589 else:
@@ -1601,7 +1601,7 @@ class Project(object):
1601 1601
1602 p = None 1602 p = None
1603 try: 1603 try:
1604 size = r.headers.get('content-length', 0) 1604 size = pos + r.headers.get('content-length', 0)
1605 unit = 1 << 10 1605 unit = 1 << 10
1606 1606
1607 if size and not quiet: 1607 if size and not quiet:
@@ -1611,7 +1611,7 @@ class Project(object):
1611 else: 1611 else:
1612 desc = 'KB' 1612 desc = 'KB'
1613 p = Progress( 1613 p = Progress(
1614 'Downloading %s' % self.relpath, 1614 'Downloading %s' % (self.relpath,),
1615 int(size) / unit, 1615 int(size) / unit,
1616 units=desc) 1616 units=desc)
1617 if pos > 0: 1617 if pos > 0: