From d7b50a3b86acf8c6683b64c887727a9d1484ebf7 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Wed, 24 Feb 2010 00:02:20 -0800 Subject: [PATCH] Additional fixes for DIR2-LIT More Info page and deep-check/manifest operations (#948) --- src/allmydata/check_results.py | 2 +- src/allmydata/dirnode.py | 14 +++++++------- src/allmydata/web/directory.py | 19 +++++++++++-------- src/allmydata/web/info.py | 5 ++++- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index 869d0f5f..7cb79705 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -99,7 +99,7 @@ class DeepResultsBase: def __init__(self, root_storage_index): self.root_storage_index = root_storage_index if root_storage_index is None: - self.root_storage_index_s = "" + self.root_storage_index_s = "" # is this correct? else: self.root_storage_index_s = base32.b2a(root_storage_index) diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 1c77330c..dc268f65 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -356,7 +356,7 @@ class DirectoryNode: def list(self): """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() def has_child(self, name): @@ -381,7 +381,7 @@ class DirectoryNode: def get(self, name): """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) d = self._read() d.addCallback(self._get, name) @@ -389,8 +389,8 @@ class DirectoryNode: def get_child_and_metadata(self, name): """I return a Deferred that fires with the (node, metadata) pair for - the named child. The node is either an IFileNode or an - IDirectoryNode, and the metadata is a dictionary.""" + the named child. The node is an IFilesystemNode, and the metadata + is a dictionary.""" assert isinstance(name, unicode) d = self._read() d.addCallback(self._get_with_metadata, name) @@ -413,7 +413,7 @@ class DirectoryNode: return d 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 descendant node. I return a Deferred that fires with the node, or @@ -427,7 +427,7 @@ class DirectoryNode: return d 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. """ @@ -832,7 +832,7 @@ class DeepChecker: root_si = root.get_storage_index() self._lp = log.msg(format="deep-check starting (%(si)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._repair = repair self._add_lease = add_lease diff --git a/src/allmydata/web/directory.py b/src/allmydata/web/directory.py index 4edb2496..d83def22 100644 --- a/src/allmydata/web/directory.py +++ b/src/allmydata/web/directory.py @@ -925,7 +925,7 @@ class ManifestResults(rend.Page, ReloadMixin): status = { "stats": s["stats"], "finished": m.is_finished(), - "origin": base32.b2a(m.origin_si), + "origin": base32.b2a(m.origin_si or ""), } if m.is_finished(): # 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) def _si_abbrev(self): - return base32.b2a(self.monitor.origin_si)[:6] + si = self.monitor.origin_si + if not si: + return "" + return base32.b2a(si)[:6] def render_title(self, ctx): return T.title["Manifest of SI=%s" % self._si_abbrev()] @@ -1044,17 +1047,17 @@ class ManifestStreamer(dirnode.DeepStats): v = node.get_verify_cap() if v: v = v.to_string() - d["verifycap"] = v + d["verifycap"] = v or "" r = node.get_repair_cap() if r: r = r.to_string() - d["repaircap"] = r + d["repaircap"] = r or "" si = node.get_storage_index() if si: si = base32.b2a(si) - d["storage-index"] = si + d["storage-index"] = si or "" j = simplejson.dumps(d, ensure_ascii=True) assert "\n" not in j @@ -1104,17 +1107,17 @@ class DeepCheckStreamer(dirnode.DeepStats): v = node.get_verify_cap() if v: v = v.to_string() - data["verifycap"] = v + data["verifycap"] = v or "" r = node.get_repair_cap() if r: r = r.to_string() - data["repaircap"] = r + data["repaircap"] = r or "" si = node.get_storage_index() if si: si = base32.b2a(si) - data["storage-index"] = si + data["storage-index"] = si or "" if self.repair: d = node.check_and_repair(self.monitor, self.verify, self.add_lease) diff --git a/src/allmydata/web/info.py b/src/allmydata/web/info.py index ae09f7b8..4a765859 100644 --- a/src/allmydata/web/info.py +++ b/src/allmydata/web/info.py @@ -86,7 +86,10 @@ class MoreInfo(rend.Page): node = self.original if not IDirectoryNode.providedBy(node): 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): node = self.original -- 2.45.2