Return an HTML-formatted manifest of the given directory, for debugging.
+GET $URL?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.
+
6. XMLRPC (coming soon)
http://localhost:8123/xmlrpc
d.addCallback(_got)
return d
+ 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)
+ d.addCallback(_got)
+ return d
+
def test_GET_DIRURL_uri(self):
d = self.GET(self.public_url + "/foo?t=uri")
def _check(res):
<div>Other representations of this directory:
<a href="?t=manifest">manifest</a>,
+<a href="?t=deep-size">total size</a>,
<a href="?t=uri">URI</a>,
<a href="?t=readonly-uri">read-only URI</a>,
<a href="?t=json">JSON</a>
IMutableFileNode
import allmydata # to display import path
from allmydata import download
+from allmydata.uri import from_string_verifier, CHKFileVerifierURI
from allmydata.upload import FileHandle, FileName
from allmydata import provisioning
from allmydata import get_package_versions_string
ctx.fillSlots("refresh_capability", refresh_cap)
return ctx.tag
+class DeepSize(rend.Page):
+
+ def __init__(self, dirnode, dirpath):
+ self._dirnode = dirnode
+ self._dirpath = dirpath
+
+ def renderHTTP(self, ctx):
+ inevow.IRequest(ctx).setHeader("content-type", "text/plain")
+ d = self._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
+ return str(total)
+ d.addCallback(_measure_size)
+ return d
+
class ChildError:
implements(inevow.IResource)
def renderHTTP(self, ctx):
return DirectoryReadonlyURI(node), ()
elif t == "manifest":
return Manifest(node, path), ()
+ elif t == "deep-size":
+ return DeepSize(node, path), ()
elif t == 'rename-form':
return RenameForm(self.name, node, path), ()
else: