Logo Search packages:      
Sourcecode: ubuntuone-client version File versions

def ubuntuone::u1sync::client::Client::build_tree (   self,
  share_uuid,
  root_uuid 
)

Builds and returns a tree representing the metadata for the given
subtree in the given share.

@param share_uuid: the share UUID or None for the user's volume
@param root_uuid: the root UUID of the subtree (must be a directory)
@return: a MergeNode tree

Definition at line 412 of file client.py.

00412                                                :
        """Builds and returns a tree representing the metadata for the given
        subtree in the given share.

        @param share_uuid: the share UUID or None for the user's volume
        @param root_uuid: the root UUID of the subtree (must be a directory)
        @return: a MergeNode tree

        """
        root = MergeNode(node_type=DIRECTORY, uuid=root_uuid)

        @inlineCallbacks
        def _get_root_content_hash():
            """Obtain the content hash for the root node."""
            result = yield self._get_node_hashes(share_uuid, [root_uuid])
            returnValue(result.get(root_uuid, None))

        root.content_hash = self.defer_from_thread(_get_root_content_hash)
        if root.content_hash is None:
            raise ValueError("No content available for node %s" % root_uuid)

        @inlineCallbacks
        def _get_children(parent_uuid, parent_content_hash):
            """Obtain a sequence of MergeNodes corresponding to a node's
            immediate children.

            """
            entries = yield self._get_raw_dir_entries(share_uuid,
                                                      parent_uuid,
                                                      parent_content_hash)
            children = {}
            for entry in entries:
                if should_sync(entry.name):
                    child = MergeNode(node_type=entry.node_type,
                                      uuid=uuid.UUID(entry.node))
                    children[entry.name] = child

            child_uuids = [child.uuid for child in children.itervalues()]
            content_hashes = yield self._get_node_hashes(share_uuid,
                                                         child_uuids)
            for child in children.itervalues():
                child.content_hash = content_hashes.get(child.uuid, None)

            returnValue(children)

        need_children = [root]
        while need_children:
            node = need_children.pop()
            if node.content_hash is not None:
                children = self.defer_from_thread(_get_children, node.uuid,
                                                  node.content_hash)
                node.children = children
                for child in children.itervalues():
                    if child.node_type == DIRECTORY:
                        need_children.append(child)

        return root

    def _get_raw_dir_entries(self, share_uuid, node_uuid, content_hash):


Generated by  Doxygen 1.6.0   Back to index