of adding initial_children= argument.
Includes stubbed-out initial_children= support.
# this returns synchronously.
return self.nodemaker.create_from_cap(writecap, readcap)
- def create_empty_dirnode(self):
- return self.nodemaker.create_new_mutable_directory()
+ def create_dirnode(self, initial_children={}):
+ d = self.nodemaker.create_new_mutable_directory()
+ assert not initial_children, "not ready yet: %s" % (initial_children,)
+ if initial_children:
+ d.addCallback(lambda n: n.set_children(initial_children))
+ return d
def create_mutable_file(self, contents="", keysize=None):
return self.nodemaker.create_mutable_file(contents, keysize)
file.
"""
- def create_empty_dirnode():
- """Create a new dirnode, empty and unattached.
+ def create_dirnode(initial_children={}):
+ """Create a new unattached dirnode, possibly with initial children.
+
+ @param initial_children: dict with keys that are unicode child names,
+ and values that are (child_writecap, child_readcap, metadata) tuples.
+
@return: a Deferred that fires with the new IDirectoryNode instance.
"""
self.basedir = "cli/List/list"
self.set_up_grid()
c0 = self.g.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.rooturi = n.get_uri()
self.uris = {}
self.fileurls = {}
DATA = "data" * 100
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.rooturi = n.get_uri()
self.set_up_grid()
c0 = self.g.clients[0]
self.fileurls = {}
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root(n):
self.rootnode = n
self.rooturi = n.get_uri()
# small2
# loop -> root
c0 = self.g.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _created_root(n):
self.root = n
self.root_uri = n.get_uri()
self.nodes = {}
c0 = self.g.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _created_root(n):
self.root = n
self.root_uri = n.get_uri()
d.addCallback(self.create_mangled, "large-missing-shares")
d.addCallback(self.create_mangled, "large-corrupt-shares")
d.addCallback(self.create_mangled, "large-unrecoverable")
- d.addCallback(lambda ignored: c0.create_empty_dirnode())
+ d.addCallback(lambda ignored: c0.create_dirnode())
d.addCallback(self._stash_node, "broken")
large1 = upload.Data("Lots of data\n" * 1000 + "large1" + "\n", None)
d.addCallback(lambda ignored:
COUNT = 400
c0 = self.g.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
self.stash = {}
def _created_root(n):
self.root = n
self.basedir = "dirnode/Dirnode/test_basic"
self.set_up_grid()
c = self.g.clients[0]
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
def _done(res):
self.failUnless(isinstance(res, dirnode.DirectoryNode))
rep = str(res)
self.basedir = "dirnode/Dirnode/test_check"
self.set_up_grid()
c = self.g.clients[0]
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
d.addCallback(lambda dn: dn.check(Monitor()))
def _done(res):
self.failUnless(res.is_healthy())
# root/subdir/link -> root
# root/rodir
c = self.g.clients[0]
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
def _created_root(rootnode):
self._rootnode = rootnode
return rootnode.create_empty_directory(u"subdir")
self._subdir = subdir
d = subdir.add_file(u"file1", upload.Data("data"*100, None))
d.addCallback(lambda res: subdir.set_node(u"link", self._rootnode))
- d.addCallback(lambda res: c.create_empty_dirnode())
+ d.addCallback(lambda res: c.create_dirnode())
d.addCallback(lambda dn:
self._rootnode.set_uri(u"rodir",
dn.get_readonly_uri()))
filenode = nm.create_from_cap(filecap)
uploadable = upload.Data("some data", convergence="some convergence string")
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
def _created(rw_dn):
d2 = rw_dn.set_uri(u"child", filecap)
d2.addCallback(lambda res: rw_dn)
self.expected_verifycaps = set()
self.expected_storage_indexes = set()
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
def _then(n):
# /
self.rootnode = n
# set_node + metadata
# it should be possible to add a child without any metadata
d.addCallback(lambda res: n.set_node(u"d2", n, {}))
- d.addCallback(lambda res: c.create_empty_dirnode())
+ d.addCallback(lambda res: c.create_dirnode())
d.addCallback(lambda n2:
self.shouldFail(ExistingChildError, "set_node-no",
"child 'd2' already exists",
self.basedir = self.mktemp()
self.set_up_grid()
c0 = self.g.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
small = upload.Data("Small enough for a LIT", None)
def _created_dir(dn):
self.root = dn
c = self.g.clients[0]
fileuri = make_chk_file_uri(1234)
filenode = c.nodemaker.create_from_cap(fileuri)
- d = c.create_empty_dirnode()
+ d = c.create_dirnode()
def _create_directory_tree(root_node):
# Build
return d1
d.addCallback(_check_empty_file)
- d.addCallback(lambda res: self.clients[0].create_empty_dirnode())
+ d.addCallback(lambda res: self.clients[0].create_dirnode())
def _created_dirnode(dnode):
log.msg("_created_dirnode(%s)" % (dnode,))
d1 = dnode.list()
d.addCallback(check_kg_poolsize, 0)
d.addCallback(lambda junk: self.clients[3].create_mutable_file('hello, world'))
d.addCallback(check_kg_poolsize, -1)
- d.addCallback(lambda junk: self.clients[3].create_empty_dirnode())
+ d.addCallback(lambda junk: self.clients[3].create_dirnode())
d.addCallback(check_kg_poolsize, -2)
# use_helper induces use of clients[3], which is the using-key_gen client
d.addCallback(lambda junk: self.POST("uri", use_helper=True, t="mkdir", name='george'))
def _do_publish1(self, res):
ut = upload.Data(self.data, convergence=None)
c0 = self.clients[0]
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _made_root(new_dirnode):
self._root_directory_uri = new_dirnode.get_uri()
return c0.create_node_from_uri(self._root_directory_uri)
def _do_publish_private(self, res):
self.smalldata = "sssh, very secret stuff"
ut = upload.Data(self.smalldata, convergence=None)
- d = self.clients[0].create_empty_dirnode()
+ d = self.clients[0].create_dirnode()
d.addCallback(self.log, "GOT private directory")
def _got_new_dir(privnode):
rootnode = self.clients[0].create_node_from_uri(self._root_directory_uri)
self.webish_port = port = self.ws.listener._port.getHost().port
self.webish_url = "http://localhost:%d" % port
- l = [ self.s.create_empty_dirnode() for x in range(6) ]
+ l = [ self.s.create_dirnode() for x in range(6) ]
d = defer.DeferredList(l)
def _then(res):
self.public_root = res[0][1]
return d
def test_PUT_DIRURL_uri(self):
- d = self.s.create_empty_dirnode()
+ d = self.s.create_dirnode()
def _made_dir(dn):
new_uri = dn.get_uri()
# replace /foo with a new (empty) directory
return d
def test_PUT_DIRURL_uri_noreplace(self):
- d = self.s.create_empty_dirnode()
+ d = self.s.create_dirnode()
def _made_dir(dn):
new_uri = dn.get_uri()
# replace /foo with a new (empty) directory, but ask that
safe="")
future_node = UnknownNode(future_writecap, future_readcap)
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.rooturl = "uri/" + urllib.quote(n.get_uri()) + "/"
self.uris = {}
self.fileurls = {}
DATA = "data" * 100
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.fileurls["root"] = "uri/" + urllib.quote(n.get_uri()) + "/"
self.uris = {}
self.fileurls = {}
DATA = "data" * 100
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.fileurls["root"] = "uri/" + urllib.quote(n.get_uri()) + "/"
self.uris = {}
self.fileurls = {}
DATA = "data" * 100
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root_and_create_file(n):
self.rootnode = n
self.uris["root"] = n.get_uri()
c0 = self.g.clients[0]
self.fileurls = {}
DATA = "data" * 100
- d = c0.create_empty_dirnode()
+ d = c0.create_dirnode()
def _stash_root(n):
self.fileurls["root"] = "uri/" + urllib.quote(n.get_uri()) + "/"
self.fileurls["imaginary"] = self.fileurls["root"] + "imaginary"
baduri = u.to_string()
self.fileurls["0shares"] = "uri/" + urllib.quote(baduri)
d.addCallback(_stash_bad)
- d.addCallback(lambda ign: c0.create_empty_dirnode())
+ d.addCallback(lambda ign: c0.create_dirnode())
def _mangle_dirnode_1share(n):
u = n.get_uri()
url = self.fileurls["dir-1share"] = "uri/" + urllib.quote(u) + "/"
self.fileurls["dir-1share-json"] = url + "?t=json"
self.delete_shares_numbered(u, range(1,10))
d.addCallback(_mangle_dirnode_1share)
- d.addCallback(lambda ign: c0.create_empty_dirnode())
+ d.addCallback(lambda ign: c0.create_dirnode())
def _mangle_dirnode_0share(n):
u = n.get_uri()
url = self.fileurls["dir-0share"] = "uri/" + urllib.quote(u) + "/"
def PUTUnlinkedCreateDirectory(req, client):
# "PUT /uri?t=mkdir", to create an unlinked directory.
- d = client.create_empty_dirnode()
+ d = client.create_dirnode()
d.addCallback(lambda dirnode: dirnode.get_uri())
# XXX add redirect_to_result
return d
def POSTUnlinkedCreateDirectory(req, client):
# "POST /uri?t=mkdir", to create an unlinked directory.
- d = client.create_empty_dirnode()
+ d = client.create_dirnode()
redirect = get_arg(req, "redirect_to_result", "false")
if boolean_of_arg(redirect):
def _then_redir(res):