mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-25 21:17:37 +00:00
webapi: fix t=rename from==to, it used to delete the file
This commit is contained in:
parent
d4b4cd8ab8
commit
a1cfac89f9
@ -1887,6 +1887,17 @@ class Web(WebMixin, testutil.StallMixin, unittest.TestCase):
|
||||
d.addCallback(self.failUnlessIsBarJSON)
|
||||
return d
|
||||
|
||||
def test_POST_rename_file_redundant(self):
|
||||
d = self.POST(self.public_url + "/foo", t="rename",
|
||||
from_name="bar.txt", to_name='bar.txt')
|
||||
d.addCallback(lambda res:
|
||||
self.failUnlessNodeHasChild(self._foo_node, u"bar.txt"))
|
||||
d.addCallback(lambda res: self.GET(self.public_url + "/foo/bar.txt"))
|
||||
d.addCallback(self.failUnlessIsBarDotTxt)
|
||||
d.addCallback(lambda res: self.GET(self.public_url + "/foo/bar.txt?t=json"))
|
||||
d.addCallback(self.failUnlessIsBarJSON)
|
||||
return d
|
||||
|
||||
def test_POST_rename_file_replace(self):
|
||||
# rename a file and replace a directory with it
|
||||
d = self.POST(self.public_url + "/foo", t="rename",
|
||||
|
@ -328,6 +328,8 @@ class DirectoryNodeHandler(RenderMixin, rend.Page, ReplaceMeMixin):
|
||||
assert isinstance(to_name, unicode)
|
||||
if not from_name or not to_name:
|
||||
raise WebError("rename requires from_name and to_name")
|
||||
if from_name == to_name:
|
||||
return defer.succeed("redundant rename")
|
||||
|
||||
# allow from_name to contain slashes, so they can fix names that were
|
||||
# accidentally created with them. But disallow them in to_name, to
|
||||
|
Loading…
x
Reference in New Issue
Block a user