提交 6588bbc9 作者: Stephen Whitmore

More thorough error checking.

License: MIT
Signed-off-by: 's avatarStephen Whitmore <noffle@ipfs.io>
上级 d30152cf
......@@ -186,7 +186,12 @@ func (adder *Adder) Finalize(write bool) (*dag.Node, error) {
if !adder.Wrap {
name = rootNode.Links[0].Name
root, err = adder.mr.GetValue().(*mfs.Directory).Child(name)
dir, ok := adder.mr.GetValue().(*mfs.Directory)
if !ok {
return nil, fmt.Errorf("root is not a directory")
}
root, err = dir.Child(name)
if err != nil {
return nil, err
}
......@@ -221,7 +226,10 @@ func (adder *Adder) outputDirs(path string, fs mfs.FSNode) error {
return nil
}
dir := fs.(*mfs.Directory)
dir, ok := fs.(*mfs.Directory)
if !ok {
return fmt.Errorf("received FSNode of type TDir that was not a Directory")
}
for _, name := range dir.ListNames() {
child, err := dir.Child(name)
......
......@@ -102,7 +102,7 @@ func PutNode(r *Root, path string, nd *dag.Node) error {
// intermediary directories as needed if 'mkparents' is set to true
func Mkdir(r *Root, pth string, mkparents bool, flush bool) (*Directory, error) {
if pth == "" {
return nil, nil
return nil, fmt.Errorf("no path given to Mkdir")
}
parts := path.SplitList(pth)
if parts[0] == "" {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论