]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webapi: fix t=rename from==to, it used to delete the file
authorBrian Warner <warner@lothar.com>
Thu, 23 Oct 2008 23:32:36 +0000 (16:32 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 23 Oct 2008 23:32:36 +0000 (16:32 -0700)
src/allmydata/test/test_web.py
src/allmydata/web/directory.py

index 54b3b463f49bba1ae541b0120a5e37dc56dc8868..d3181ba83f62088e0bf891d2aae84c40cd7e770a 100644 (file)
@@ -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",
index 3501fa72eb90776966977e8f380e533d896deb6e..0612b87c7a3249b0379e1b359c0481eacd8b26a7 100644 (file)
@@ -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