Additional fixes for DIR2-LIT More Info page and deep-check/manifest operations (#948)

This commit is contained in:
david-sarah
2010-02-24 00:02:20 -08:00
parent e6aee33bb7
commit d7b50a3b86
4 changed files with 23 additions and 17 deletions

View File

@ -99,7 +99,7 @@ class DeepResultsBase:
def __init__(self, root_storage_index): def __init__(self, root_storage_index):
self.root_storage_index = root_storage_index self.root_storage_index = root_storage_index
if root_storage_index is None: if root_storage_index is None:
self.root_storage_index_s = "<none>" self.root_storage_index_s = "<none>" # is this correct?
else: else:
self.root_storage_index_s = base32.b2a(root_storage_index) self.root_storage_index_s = base32.b2a(root_storage_index)

View File

@ -356,7 +356,7 @@ class DirectoryNode:
def list(self): def list(self):
"""I return a Deferred that fires with a dictionary mapping child """I return a Deferred that fires with a dictionary mapping child
name to a tuple of (IFileNode or IDirectoryNode, metadata).""" name to a tuple of (IFilesystemNode, metadata)."""
return self._read() return self._read()
def has_child(self, name): def has_child(self, name):
@ -381,7 +381,7 @@ class DirectoryNode:
def get(self, name): def get(self, name):
"""I return a Deferred that fires with the named child node, """I return a Deferred that fires with the named child node,
which is either an IFileNode or an IDirectoryNode.""" which is an IFilesystemNode."""
assert isinstance(name, unicode) assert isinstance(name, unicode)
d = self._read() d = self._read()
d.addCallback(self._get, name) d.addCallback(self._get, name)
@ -389,8 +389,8 @@ class DirectoryNode:
def get_child_and_metadata(self, name): def get_child_and_metadata(self, name):
"""I return a Deferred that fires with the (node, metadata) pair for """I return a Deferred that fires with the (node, metadata) pair for
the named child. The node is either an IFileNode or an the named child. The node is an IFilesystemNode, and the metadata
IDirectoryNode, and the metadata is a dictionary.""" is a dictionary."""
assert isinstance(name, unicode) assert isinstance(name, unicode)
d = self._read() d = self._read()
d.addCallback(self._get_with_metadata, name) d.addCallback(self._get_with_metadata, name)
@ -413,7 +413,7 @@ class DirectoryNode:
return d return d
def get_child_at_path(self, path): def get_child_at_path(self, path):
"""Transform a child path into an IDirectoryNode or IFileNode. """Transform a child path into an IFilesystemNode.
I perform a recursive series of 'get' operations to find the named I perform a recursive series of 'get' operations to find the named
descendant node. I return a Deferred that fires with the node, or descendant node. I return a Deferred that fires with the node, or
@ -427,7 +427,7 @@ class DirectoryNode:
return d return d
def get_child_and_metadata_at_path(self, path): def get_child_and_metadata_at_path(self, path):
"""Transform a child path into an IDirectoryNode or IFileNode and """Transform a child path into an IFilesystemNode and
a metadata dictionary from the last edge that was traversed. a metadata dictionary from the last edge that was traversed.
""" """
@ -832,7 +832,7 @@ class DeepChecker:
root_si = root.get_storage_index() root_si = root.get_storage_index()
self._lp = log.msg(format="deep-check starting (%(si)s)," self._lp = log.msg(format="deep-check starting (%(si)s),"
" verify=%(verify)s, repair=%(repair)s", " verify=%(verify)s, repair=%(repair)s",
si=base32.b2a(root_si), verify=verify, repair=repair) si=base32.b2a(root_si or ""), verify=verify, repair=repair)
self._verify = verify self._verify = verify
self._repair = repair self._repair = repair
self._add_lease = add_lease self._add_lease = add_lease

View File

@ -925,7 +925,7 @@ class ManifestResults(rend.Page, ReloadMixin):
status = { "stats": s["stats"], status = { "stats": s["stats"],
"finished": m.is_finished(), "finished": m.is_finished(),
"origin": base32.b2a(m.origin_si), "origin": base32.b2a(m.origin_si or ""),
} }
if m.is_finished(): if m.is_finished():
# don't return manifest/verifycaps/SIs unless the operation is # don't return manifest/verifycaps/SIs unless the operation is
@ -946,7 +946,10 @@ class ManifestResults(rend.Page, ReloadMixin):
return simplejson.dumps(status, indent=1) return simplejson.dumps(status, indent=1)
def _si_abbrev(self): def _si_abbrev(self):
return base32.b2a(self.monitor.origin_si)[:6] si = self.monitor.origin_si
if not si:
return "<LIT>"
return base32.b2a(si)[:6]
def render_title(self, ctx): def render_title(self, ctx):
return T.title["Manifest of SI=%s" % self._si_abbrev()] return T.title["Manifest of SI=%s" % self._si_abbrev()]
@ -1044,17 +1047,17 @@ class ManifestStreamer(dirnode.DeepStats):
v = node.get_verify_cap() v = node.get_verify_cap()
if v: if v:
v = v.to_string() v = v.to_string()
d["verifycap"] = v d["verifycap"] = v or ""
r = node.get_repair_cap() r = node.get_repair_cap()
if r: if r:
r = r.to_string() r = r.to_string()
d["repaircap"] = r d["repaircap"] = r or ""
si = node.get_storage_index() si = node.get_storage_index()
if si: if si:
si = base32.b2a(si) si = base32.b2a(si)
d["storage-index"] = si d["storage-index"] = si or ""
j = simplejson.dumps(d, ensure_ascii=True) j = simplejson.dumps(d, ensure_ascii=True)
assert "\n" not in j assert "\n" not in j
@ -1104,17 +1107,17 @@ class DeepCheckStreamer(dirnode.DeepStats):
v = node.get_verify_cap() v = node.get_verify_cap()
if v: if v:
v = v.to_string() v = v.to_string()
data["verifycap"] = v data["verifycap"] = v or ""
r = node.get_repair_cap() r = node.get_repair_cap()
if r: if r:
r = r.to_string() r = r.to_string()
data["repaircap"] = r data["repaircap"] = r or ""
si = node.get_storage_index() si = node.get_storage_index()
if si: if si:
si = base32.b2a(si) si = base32.b2a(si)
data["storage-index"] = si data["storage-index"] = si or ""
if self.repair: if self.repair:
d = node.check_and_repair(self.monitor, self.verify, self.add_lease) d = node.check_and_repair(self.monitor, self.verify, self.add_lease)

View File

@ -86,7 +86,10 @@ class MoreInfo(rend.Page):
node = self.original node = self.original
if not IDirectoryNode.providedBy(node): if not IDirectoryNode.providedBy(node):
return "" return ""
return ctx.tag[node.get_verify_cap().to_string()] verifier = node.get_verify_cap()
if verifier:
return ctx.tag[node.get_verify_cap().to_string()]
return ""
def render_file_writecap(self, ctx, data): def render_file_writecap(self, ctx, data):
node = self.original node = self.original