GET $DIRURL?t=deep-size
Return a number (in bytes) containing the sum of the filesize of all
- immutable files reachable from the given directory. This is a rough lower
- bound of the total space consumed by this subtree. It does not include
- space consumed by directories or immutable files, nor does it take
- expansion or encoding overhead into account. Later versions of the code may
- improve this estimate upwards.
+ directories and immutable files reachable from the given directory. This is
+ a rough lower bound of the total space consumed by this subtree. It does
+ not include space consumed by mutable files, nor does it take expansion or
+ encoding overhead into account. Later versions of the code may improve this
+ estimate upwards.
GET $DIRURL?t=deep-stats
def test_GET_DIRURL_deepsize(self):
d = self.GET(self.public_url + "/foo?t=deep-size", followRedirect=True)
- def _got(manifest):
- self.failUnless(re.search(r'^\d+$', manifest), manifest)
- self.failUnlessEqual("57", manifest)
+ def _got(res):
+ self.failUnless(re.search(r'^\d+$', res), res)
+ size = int(res)
+ # with directories, the size varies. I've seen 1967 to 1979
+ self.failUnless(abs(size-1973) < 10, size)
d.addCallback(_got)
return d
return ctx.tag
def DeepSize(ctx, dirnode):
- d = dirnode.build_manifest()
- def _measure_size(manifest):
- total = 0
- for verifiercap in manifest:
- u = from_string_verifier(verifiercap)
- if isinstance(u, CHKFileVerifierURI):
- total += u.size
+ d = dirnode.deep_stats()
+ def _measure_size(stats):
+ total = (stats.get("size-immutable-files", 0)
+ + stats.get("size-mutable-files", 0)
+ + stats.get("size-directories", 0))
return str(total)
d.addCallback(_measure_size)
d.addCallback(text_plain, ctx)