Patch to accept t=set-children as well as t=set_children

This commit is contained in:
david-sarah 2010-01-23 19:00:20 -08:00
parent 584c0ed487
commit 5c5a6fe610
3 changed files with 12 additions and 3 deletions

View File

@ -666,6 +666,7 @@ PUT /uri/$DIRCAP/[SUBDIRS../]CHILDNAME?t=uri
=== Adding multiple files or directories to a parent directory at once === === Adding multiple files or directories to a parent directory at once ===
POST /uri/$DIRCAP/[SUBDIRS..]?t=set_children POST /uri/$DIRCAP/[SUBDIRS..]?t=set_children
POST /uri/$DIRCAP/[SUBDIRS..]?t=set-children (Tahoe >= v1.6)
This command adds multiple children to a directory in a single operation. This command adds multiple children to a directory in a single operation.
It reads the request body and interprets it as a JSON-encoded description It reads the request body and interprets it as a JSON-encoded description
@ -694,6 +695,11 @@ POST /uri/$DIRCAP/[SUBDIRS..]?t=set_children
currently placed here are "linkcrtime" and "linkmotime". For details, see currently placed here are "linkcrtime" and "linkmotime". For details, see
the section above entitled "Get Information About A File Or Directory (as the section above entitled "Get Information About A File Or Directory (as
JSON)", in the "About the metadata" subsection. JSON)", in the "About the metadata" subsection.
Note that this command was introduced with the name "set_children", which
uses an underscore rather than a hyphen as other multi-word command names
do. The variant with a hyphen is now accepted, but clients that desire
backward compatibility should continue to use "set_children".
=== Deleting a File or Directory === === Deleting a File or Directory ===

View File

@ -2236,7 +2236,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
self.POST, self.public_url + "/foo", t="BOGUS") self.POST, self.public_url + "/foo", t="BOGUS")
return d return d
def test_POST_set_children(self): def test_POST_set_children(self, command_name="set_children"):
contents9, n9, newuri9 = self.makefile(9) contents9, n9, newuri9 = self.makefile(9)
contents10, n10, newuri10 = self.makefile(10) contents10, n10, newuri10 = self.makefile(10)
contents11, n11, newuri11 = self.makefile(11) contents11, n11, newuri11 = self.makefile(11)
@ -2265,7 +2265,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
} ] } ]
}""" % (newuri9, newuri10, newuri11) }""" % (newuri9, newuri10, newuri11)
url = self.webish_url + self.public_url + "/foo" + "?t=set_children" url = self.webish_url + self.public_url + "/foo" + "?t=" + command_name
d = client.getPage(url, method="POST", postdata=reqbody) d = client.getPage(url, method="POST", postdata=reqbody)
def _then(res): def _then(res):
@ -2277,6 +2277,9 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
d.addErrback(self.dump_error) d.addErrback(self.dump_error)
return d return d
def test_POST_set_children_with_hyphen(self):
return self.test_POST_set_children(command_name="set-children")
def test_POST_put_uri(self): def test_POST_put_uri(self):
contents, n, newuri = self.makefile(8) contents, n, newuri = self.makefile(8)
d = self.POST(self.public_url + "/foo", t="uri", name="new.txt", uri=newuri) d = self.POST(self.public_url + "/foo", t="uri", name="new.txt", uri=newuri)

View File

@ -220,7 +220,7 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
d = self._POST_start_deep_stats(ctx) d = self._POST_start_deep_stats(ctx)
elif t == "stream-manifest": elif t == "stream-manifest":
d = self._POST_stream_manifest(ctx) d = self._POST_stream_manifest(ctx)
elif t == "set_children": elif t == "set_children" or t == "set-children":
d = self._POST_set_children(req) d = self._POST_set_children(req)
else: else:
raise WebError("POST to a directory with bad t=%s" % t) raise WebError("POST to a directory with bad t=%s" % t)