mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
web: handle PUT mutable=true properly
This commit is contained in:
parent
d72f75019f
commit
e323019708
@ -587,6 +587,24 @@ class Web(WebMixin, unittest.TestCase):
|
||||
self.NEWFILE_CONTENTS))
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILEURL_mutable(self):
|
||||
d = self.PUT(self.public_url + "/foo/new.txt?mutable=true",
|
||||
self.NEWFILE_CONTENTS)
|
||||
# TODO: we lose the response code, so we can't check this
|
||||
#self.failUnlessEqual(responsecode, 201)
|
||||
def _check_uri(res):
|
||||
u = uri.from_string_mutable_filenode(res)
|
||||
self.failUnless(u.is_mutable())
|
||||
self.failIf(u.is_readonly())
|
||||
return res
|
||||
d.addCallback(_check_uri)
|
||||
d.addCallback(self.failUnlessURIMatchesChild, self._foo_node, u"new.txt")
|
||||
d.addCallback(lambda res:
|
||||
self.failUnlessMutableChildContentsAre(self._foo_node,
|
||||
u"new.txt",
|
||||
self.NEWFILE_CONTENTS))
|
||||
return d
|
||||
|
||||
def test_PUT_NEWFILEURL_replace(self):
|
||||
d = self.PUT(self.public_url + "/foo/bar.txt", self.NEWFILE_CONTENTS)
|
||||
# TODO: we lose the response code, so we can't check this
|
||||
|
@ -22,8 +22,21 @@ class ReplaceMeMixin:
|
||||
# a new file is being uploaded in our place.
|
||||
req = IRequest(ctx)
|
||||
client = IClient(ctx)
|
||||
uploadable = FileHandle(req.content, convergence=client.convergence)
|
||||
d = self.parentnode.add_file(self.name, uploadable, overwrite=replace)
|
||||
mutable = boolean_of_arg(get_arg(req, "mutable", "false"))
|
||||
if mutable:
|
||||
req.content.seek(0)
|
||||
data = req.content.read()
|
||||
d = client.create_mutable_file(data)
|
||||
def _uploaded(newnode):
|
||||
d2 = self.parentnode.set_node(self.name, newnode,
|
||||
overwrite=replace)
|
||||
d2.addCallback(lambda res: newnode)
|
||||
return d2
|
||||
d.addCallback(_uploaded)
|
||||
else:
|
||||
uploadable = FileHandle(req.content, convergence=client.convergence)
|
||||
d = self.parentnode.add_file(self.name, uploadable,
|
||||
overwrite=replace)
|
||||
def _done(filenode):
|
||||
log.msg("webish upload complete",
|
||||
facility="tahoe.webish", level=log.NOISY)
|
||||
|
Loading…
Reference in New Issue
Block a user