Ejemplo n.º 1
0
func (v *Vault) DeleteTree(root string) error {
	tree, err := v.Tree(root, TreeOptions{})
	if err != nil {
		return err
	}
	for _, path := range tree.Paths("/") {
		err = v.Delete(path)
		if err != nil {
			return err
		}
	}
	return v.Delete(root)
}
Ejemplo n.º 2
0
func (v *Vault) MoveCopyTree(oldRoot, newRoot string, f func(string, string) error) error {
	tree, err := v.Tree(oldRoot, TreeOptions{})
	if err != nil {
		return err
	}
	for _, path := range tree.Paths("/") {
		newPath := strings.Replace(path, oldRoot, newRoot, 1)
		err = f(path, newPath)
		if err != nil {
			return err
		}
	}

	if _, err := v.Read(oldRoot); !IsNotFound(err) { // run through a copy unless we successfully got a 404 from this node
		return f(oldRoot, newRoot)
	}
	return nil
}