From: frederik b Date: Fri, 28 Sep 2012 17:22:53 +0000 (+0200) Subject: fixed wrong index in tahoe cp --verbose, as explained in #1805 X-Git-Tag: allmydata-tahoe-1.10a1~53 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/nxhtml.html?a=commitdiff_plain;h=595d611c9b4b29c8ca73faaf7ce16ad4fe2e861a;p=tahoe-lafs%2Ftahoe-lafs.git fixed wrong index in tahoe cp --verbose, as explained in #1805 this bug shows wrong counters for copied files in verbose mode --- diff --git a/src/allmydata/scripts/tahoe_cp.py b/src/allmydata/scripts/tahoe_cp.py index 13537dc0..f2f8c922 100644 --- a/src/allmydata/scripts/tahoe_cp.py +++ b/src/allmydata/scripts/tahoe_cp.py @@ -103,7 +103,7 @@ class LocalDirectorySource: self.children = {} children = listdir_unicode(self.pathname) for i,n in enumerate(children): - self.progressfunc("examining %d of %d" % (i, len(children))) + self.progressfunc("examining %d of %d" % (i+1, len(children))) pn = os.path.join(self.pathname, n) if os.path.isdir(pn): child = LocalDirectorySource(self.progressfunc, pn) @@ -131,7 +131,7 @@ class LocalDirectoryTarget: self.children = {} children = listdir_unicode(self.pathname) for i,n in enumerate(children): - self.progressfunc("examining %d of %d" % (i, len(children))) + self.progressfunc("examining %d of %d" % (i+1, len(children))) n = unicode(n) pn = os.path.join(self.pathname, n) if os.path.isdir(pn): @@ -239,7 +239,7 @@ class TahoeDirectorySource: return self.children = {} for i,(name, data) in enumerate(self.children_d.items()): - self.progressfunc("examining %d of %d" % (i, len(self.children_d))) + self.progressfunc("examining %d of %d" % (i+1, len(self.children_d))) if data[0] == "filenode": mutable = data[1].get("mutable", False) writecap = to_str(data[1].get("rw_uri")) @@ -333,7 +333,7 @@ class TahoeDirectoryTarget: return self.children = {} for i,(name, data) in enumerate(self.children_d.items()): - self.progressfunc("examining %d of %d" % (i, len(self.children_d))) + self.progressfunc("examining %d of %d" % (i+1, len(self.children_d))) if data[0] == "filenode": mutable = data[1].get("mutable", False) writecap = to_str(data[1].get("rw_uri")) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index e3d0f4c6..c2dad120 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -2031,6 +2031,12 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase): results = fileutil.read(fn3) self.failUnlessReallyEqual(results, DATA1) d.addCallback(_get_resp2) + # cp --verbose filename3 dircap:test_file + d.addCallback(lambda ign: + self.do_cli("cp", "--verbose", '--recursive', self.basedir, self.dircap)) + def _test_for_wrong_indices((rc, out, err)): + self.failUnless('examining 1 of 1\n' in err) + d.addCallback(_test_for_wrong_indices) return d def test_cp_with_nonexistent_alias(self):