Changeset d71adaf in trunk


Ignore:
Timestamp:
2009-07-04T03:43:01Z (16 years ago)
Author:
kevan <kevan@…>
Branches:
master
Children:
5501983
Parents:
34213cd
Message:

Use CachingDict? instead of dict in dirnode.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/dirnode.py

    r34213cd rd71adaf  
    171171        # URI to create our own.
    172172        self._node = self.filenode_class(self._client)
    173         empty_contents = self._pack_contents({})
     173        empty_contents = self._pack_contents(CachingDict())
    174174        d = self._node.create(empty_contents, keypair_generator, keysize=keysize)
    175175        d.addCallback(self._filenode_created)
     
    225225        # an empty directory is serialized as an empty string
    226226        if data == "":
    227             return {}
     227            return CachingDict()
    228228        writeable = not self.is_readonly()
    229         children = {}
     229        children = CachingDict()
    230230        position = 0
    231231        while position < len(data):
     
    244244            metadata = simplejson.loads(metadata_s)
    245245            assert isinstance(metadata, dict)
    246             children[name] = (child, metadata)
     246            children.set_both_items(name, entry, (child, metadata))
    247247        return children
    248248
    249249    def _pack_contents(self, children):
    250250        # expects children in the same format as _unpack_contents
    251         assert isinstance(children, dict)
     251        assert isinstance(children, CachingDict)
    252252        entries = []
    253253        for name in sorted(children.keys()):
    254             child, metadata = children[name]
    255             assert isinstance(name, unicode)
    256             assert IFilesystemNode.providedBy(child), (name,child)
    257             assert isinstance(metadata, dict)
    258             rwcap = child.get_uri() # might be RO if the child is not writeable
    259             if rwcap is None:
    260                 rwcap = ""
    261             assert isinstance(rwcap, str), rwcap
    262             rocap = child.get_readonly_uri()
    263             if rocap is None:
    264                 rocap = ""
    265             assert isinstance(rocap, str), rocap
    266             entry = "".join([netstring(name.encode("utf-8")),
     254            entry, metadata = children.get_both_items(name)
     255            if entry == None:
     256                child, metadata = metadata
     257                assert isinstance(name, unicode)
     258                assert IFilesystemNode.providedBy(child), (name,child)
     259                assert isinstance(metadata, dict)
     260                rwcap = child.get_uri() # might be RO if the child is not writeable
     261                if rwcap is None:
     262                    rwcap = ""
     263                assert isinstance(rwcap, str), rwcap
     264                rocap = child.get_readonly_uri()
     265                if rocap is None:
     266                    rocap = ""
     267                assert isinstance(rocap, str), rocap
     268                entry = "".join([netstring(name.encode("utf-8")),
    267269                             netstring(rocap),
    268270                             netstring(self._encrypt_rwcap(rwcap)),
Note: See TracChangeset for help on using the changeset viewer.