Esempio n. 1
0
func (fs *nomsFS) getNode(inode types.Struct, name string, parent *nNode) *nNode {
	// The parent has to be a directory.
	if parent != nil {
		d.Chk.Equal("Directory", nodeType(parent.inode))
	}

	np, ok := fs.nodes[inode.Hash()]
	if ok {
		d.Chk.Equal(np.parent, parent)
		d.Chk.Equal(np.name, name)
	} else {
		np = &nNode{
			nLock:  &sync.Mutex{},
			parent: parent,
			name:   name,
			key:    inode.Hash(),
			inode:  inode,
		}
		fs.nodes[np.key] = np
	}
	return np
}
Esempio n. 2
0
func (fs *nomsFS) updateNode(np *nNode, inode types.Struct) {
	delete(fs.nodes, np.key)
	np.inode = inode
	np.key = inode.Hash()
	fs.nodes[np.key] = np
}