From: Brian Warner Date: Tue, 13 Oct 2009 01:50:26 +0000 (-0700) Subject: dirnode.set_children: change return value: fire with self instead of None X-Git-Tag: trac-4100~20 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/flags?a=commitdiff_plain;h=d079eb45f6581c270c7f47548725d19bef901750;p=tahoe-lafs%2Ftahoe-lafs.git dirnode.set_children: change return value: fire with self instead of None --- diff --git a/src/allmydata/dirnode.py b/src/allmydata/dirnode.py index 4a2e751f..c7e6f56f 100644 --- a/src/allmydata/dirnode.py +++ b/src/allmydata/dirnode.py @@ -415,7 +415,9 @@ class DirectoryNode: msg = "cannot pack unknown node as child %s" % str(name) raise CannotPackUnknownNodeError(msg) a.set_node(name, child_node, metadata) - return self._node.modify(a.modify) + d = self._node.modify(a.modify) + d.addCallback(lambda ign: self) + return d def set_node(self, name, child, metadata=None, overwrite=True): """I add a child at the specific name. I return a Deferred that fires diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py index f07788f5..42ec62c0 100644 --- a/src/allmydata/interfaces.py +++ b/src/allmydata/interfaces.py @@ -901,9 +901,9 @@ class IDirectoryNode(IMutableFilesystemNode): """Add multiple children (by writecap+readcap) to a directory node. Takes a dictionary, with childname as keys and (writecap, readcap) tuples (or (writecap, readcap, metadata) triples) as values. Returns - a Deferred that fires (with None) when the operation finishes. This - is equivalent to calling set_uri() multiple times, but is much more - efficient. All child names must be unicode strings. + a Deferred that fires (with this dirnode) when the operation + finishes. This is equivalent to calling set_uri() multiple times, but + is much more efficient. All child names must be unicode strings. """ def set_node(name, child, metadata=None, overwrite=True): diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index c6841170..097a9a15 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -455,6 +455,7 @@ class Dirnode(GridTestMixin, unittest.TestCase, u"e3": (fake_file_uri, fake_file_uri, {"key": "value"}), })) + d.addCallback(lambda n2: self.failUnlessIdentical(n2, n)) d.addCallback(lambda res: self.shouldFail(ExistingChildError, "set_children-no", "child 'e1' already exists",