mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
addendum to "Fix 'tahoe ls' on files (#771)"
tahoe_ls.py: tolerate missing metadata web/filenode.py: minor cleanups test_cli.py: test 'tahoe ls FILECAP'
This commit is contained in:
parent
a8a768ef9d
commit
00d0ca3902
@ -53,6 +53,8 @@ def list(options):
|
|||||||
elif nodetype == "filenode":
|
elif nodetype == "filenode":
|
||||||
childname = path.split("/")[-1]
|
childname = path.split("/")[-1]
|
||||||
children = {childname: (nodetype, d)}
|
children = {childname: (nodetype, d)}
|
||||||
|
if "metadata" not in d:
|
||||||
|
d["metadata"] = {}
|
||||||
childnames = sorted(children.keys())
|
childnames = sorted(children.keys())
|
||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
|
@ -748,12 +748,16 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
self.basedir = "cli/List/list"
|
self.basedir = "cli/List/list"
|
||||||
self.set_up_grid()
|
self.set_up_grid()
|
||||||
c0 = self.g.clients[0]
|
c0 = self.g.clients[0]
|
||||||
|
small = "small"
|
||||||
d = c0.create_dirnode()
|
d = c0.create_dirnode()
|
||||||
def _stash_root_and_create_file(n):
|
def _stash_root_and_create_file(n):
|
||||||
self.rootnode = n
|
self.rootnode = n
|
||||||
self.rooturi = n.get_uri()
|
self.rooturi = n.get_uri()
|
||||||
return n.add_file(u"good", upload.Data("small", convergence=""))
|
return n.add_file(u"good", upload.Data(small, convergence=""))
|
||||||
d.addCallback(_stash_root_and_create_file)
|
d.addCallback(_stash_root_and_create_file)
|
||||||
|
def _stash_goodcap(n):
|
||||||
|
self.goodcap = n.get_uri()
|
||||||
|
d.addCallback(_stash_goodcap)
|
||||||
d.addCallback(lambda ign: self.rootnode.create_subdirectory(u"1share"))
|
d.addCallback(lambda ign: self.rootnode.create_subdirectory(u"1share"))
|
||||||
d.addCallback(lambda n:
|
d.addCallback(lambda n:
|
||||||
self.delete_shares_numbered(n.get_uri(), range(1,10)))
|
self.delete_shares_numbered(n.get_uri(), range(1,10)))
|
||||||
@ -786,10 +790,21 @@ class List(GridTestMixin, CLITestMixin, unittest.TestCase):
|
|||||||
d.addCallback(lambda ign: self.do_cli("ls", "0share"))
|
d.addCallback(lambda ign: self.do_cli("ls", "0share"))
|
||||||
d.addCallback(_check3)
|
d.addCallback(_check3)
|
||||||
def _check4((rc, out, err)):
|
def _check4((rc, out, err)):
|
||||||
|
# listing a file (as dir/filename) should have the edge metadata,
|
||||||
|
# including the filename
|
||||||
self.failUnlessEqual(rc, 0)
|
self.failUnlessEqual(rc, 0)
|
||||||
self.failUnlessIn("good", out)
|
self.failUnlessIn("good", out)
|
||||||
d.addCallback(lambda ign: self.do_cli("ls", "good"))
|
self.failIfIn("-r-- %d -" % len(small), out,
|
||||||
|
"trailing hyphen means unknown date")
|
||||||
|
d.addCallback(lambda ign: self.do_cli("ls", "-l", "good"))
|
||||||
d.addCallback(_check4)
|
d.addCallback(_check4)
|
||||||
|
def _check5((rc, out, err)):
|
||||||
|
# listing a raw filecap should not explode, but it will have no
|
||||||
|
# metadata, just the size
|
||||||
|
self.failUnlessEqual(rc, 0)
|
||||||
|
self.failUnlessEqual("-r-- %d -" % len(small), out.strip())
|
||||||
|
d.addCallback(lambda ign: self.do_cli("ls", "-l", self.goodcap))
|
||||||
|
d.addCallback(_check5)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
class Mv(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||||
|
@ -426,7 +426,7 @@ class FileDownloader(rend.Page):
|
|||||||
return req.deferred
|
return req.deferred
|
||||||
|
|
||||||
|
|
||||||
def FileJSONMetadata(ctx, filenode, edge_metadata=None):
|
def FileJSONMetadata(ctx, filenode, edge_metadata):
|
||||||
if filenode.is_readonly():
|
if filenode.is_readonly():
|
||||||
rw_uri = None
|
rw_uri = None
|
||||||
ro_uri = filenode.get_uri()
|
ro_uri = filenode.get_uri()
|
||||||
@ -443,8 +443,8 @@ def FileJSONMetadata(ctx, filenode, edge_metadata=None):
|
|||||||
if verifycap:
|
if verifycap:
|
||||||
data[1]['verify_uri'] = verifycap.to_string()
|
data[1]['verify_uri'] = verifycap.to_string()
|
||||||
data[1]['mutable'] = filenode.is_mutable()
|
data[1]['mutable'] = filenode.is_mutable()
|
||||||
if edge_metadata:
|
if edge_metadata is not None:
|
||||||
data[1]["metadata"] = edge_metadata
|
data[1]['metadata'] = edge_metadata
|
||||||
return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx)
|
return text_plain(simplejson.dumps(data, indent=1) + "\n", ctx)
|
||||||
|
|
||||||
def FileURI(ctx, filenode):
|
def FileURI(ctx, filenode):
|
||||||
|
Loading…
Reference in New Issue
Block a user