mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 14:52:26 +00:00
webish: add edge metadata to t=json output, including timestamps
This commit is contained in:
parent
1f7b980a51
commit
a70fba4ef1
@ -94,7 +94,7 @@ d. examining files or directories
|
||||
|
||||
GET $URL?t=json
|
||||
|
||||
out: json metadata
|
||||
out: json description of $URL
|
||||
|
||||
This returns machine-parseable information about the indicated file or
|
||||
directory in the HTTP response body. The JSON always contains a list, and
|
||||
@ -104,28 +104,49 @@ d. examining files or directories
|
||||
If it is a file, then the information includes file size and URI, like
|
||||
this:
|
||||
|
||||
[ 'filenode', { 'ro_uri': file_uri,
|
||||
'size': bytes } ]
|
||||
GET $FILEURL?t=json :
|
||||
|
||||
[ 'filenode', { 'ro_uri': file_uri,
|
||||
'size': bytes,
|
||||
'metadata': {'ctime': 1202777696.7564139,
|
||||
'mtime': 1202777696.7564139,
|
||||
},
|
||||
} ]
|
||||
|
||||
If it is a directory, then it includes information about the children of
|
||||
this directory, as a mapping from child name to a set of metadata about the
|
||||
this directory, as a mapping from child name to a set of data about the
|
||||
child (the same data that would appear in a corresponding GET?t=json of the
|
||||
child itself). Like this:
|
||||
child itself). The child entries also include metadata about each child,
|
||||
including creation- and modification- timestamps. The output looks like
|
||||
this:
|
||||
|
||||
[ 'dirnode', { 'rw_uri': read_write_uri,
|
||||
'ro_uri': read_only_uri,
|
||||
'children': children } ]
|
||||
GET $DIRURL?t=json :
|
||||
|
||||
In the above example, 'children' is a dictionary in which the keys are
|
||||
child names and the values depend upon whether the child is a file or a
|
||||
directory:
|
||||
[ 'dirnode', { 'rw_uri': read_write_uri,
|
||||
'ro_uri': read_only_uri,
|
||||
'children': [
|
||||
'foo.txt': [ 'filenode', { 'ro_uri': uri,
|
||||
'size': bytes,
|
||||
'metadata': {
|
||||
'ctime': 1202777696.7564139,
|
||||
'mtime': 1202777696.7564139,
|
||||
},
|
||||
} ],
|
||||
'subdir': [ 'dirnode', { 'rw_uri': rwuri,
|
||||
'ro_uri': rouri,
|
||||
'metadata': {
|
||||
'ctime': 1202778102.7589991,
|
||||
'mtime': 1202778111.2160511,
|
||||
},
|
||||
} ],
|
||||
] } ]
|
||||
|
||||
'foo.txt': [ 'filenode', { 'ro_uri': uri, 'size': bytes } ]
|
||||
'subdir': [ 'dirnode', { 'rw_uri': rwuri, 'ro_uri': rouri } ]
|
||||
|
||||
note that the value is the same as the JSON representation of the child
|
||||
object (except that directories do not recurse -- the "children" entry of
|
||||
the child is omitted).
|
||||
In the above example, note how 'children' is a dictionary in which the keys
|
||||
are child names and the values depend upon whether the child is a file or a
|
||||
directory. The value is mostly the same as the JSON representation of the
|
||||
child object (except that directories do not recurse -- the "children"
|
||||
entry of the child is omitted, and the directory view includes the metadata
|
||||
that is stored on the directory edge).
|
||||
|
||||
Then the rw_uri field will be present in the information about a directory
|
||||
if and only if you have read-write access to that directory,
|
||||
|
@ -96,6 +96,7 @@ class WebMixin(object):
|
||||
|
||||
self.BAR_CONTENTS, n, self._bar_txt_uri = self.makefile(0)
|
||||
foo.set_uri("bar.txt", self._bar_txt_uri)
|
||||
|
||||
foo.set_uri("empty", res[3][1].get_uri())
|
||||
sub_uri = res[4][1].get_uri()
|
||||
foo.set_uri("sub", sub_uri)
|
||||
@ -125,7 +126,12 @@ class WebMixin(object):
|
||||
# public/reedownlee/
|
||||
# public/reedownlee/nor
|
||||
self.NEWFILE_CONTENTS = "newfile contents\n"
|
||||
|
||||
return foo.get_metadata_for("bar.txt")
|
||||
d.addCallback(_then)
|
||||
def _got_metadata(metadata):
|
||||
self._bar_txt_metadata = metadata
|
||||
d.addCallback(_got_metadata)
|
||||
return d
|
||||
|
||||
def makefile(self, number):
|
||||
@ -162,9 +168,14 @@ class WebMixin(object):
|
||||
["bar.txt", "blockingfile", "empty", "sub"])
|
||||
kids = data[1]["children"]
|
||||
self.failUnlessEqual(kids["sub"][0], "dirnode")
|
||||
self.failUnless("metadata" in kids["sub"][1])
|
||||
self.failUnless("ctime" in kids["sub"][1]["metadata"])
|
||||
self.failUnless("mtime" in kids["sub"][1]["metadata"])
|
||||
self.failUnlessEqual(kids["bar.txt"][0], "filenode")
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["size"], len(self.BAR_CONTENTS))
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["ro_uri"], self._bar_txt_uri)
|
||||
self.failUnlessEqual(kids["bar.txt"][1]["metadata"]["ctime"],
|
||||
self._bar_txt_metadata["ctime"])
|
||||
|
||||
def GET(self, urlpath, followRedirect=False):
|
||||
url = self.webish_url + urlpath
|
||||
|
@ -656,11 +656,13 @@ class DirectoryJSONMetadata(rend.Page):
|
||||
kiddata = ("filenode",
|
||||
{'ro_uri': kiduri,
|
||||
'size': childnode.get_size(),
|
||||
'metadata': metadata,
|
||||
})
|
||||
else:
|
||||
assert IDirectoryNode.providedBy(childnode), (childnode, children,)
|
||||
kiddata = ("dirnode",
|
||||
{'ro_uri': childnode.get_readonly_uri(),
|
||||
'metadata': metadata,
|
||||
})
|
||||
if not childnode.is_readonly():
|
||||
kiddata[1]['rw_uri'] = childnode.get_uri()
|
||||
|
Loading…
Reference in New Issue
Block a user