Unverified 提交 2c2d2e2a 作者: Steven Allen 提交者: GitHub

Merge pull request #5936 from ipfs/fix/mfs-flush

mfs: make sure to flush after mv and chcid
...@@ -636,6 +636,8 @@ Example: ...@@ -636,6 +636,8 @@ Example:
return err return err
} }
flush, _ := req.Options[filesFlushOptionName].(bool)
src, err := checkPath(req.Arguments[0]) src, err := checkPath(req.Arguments[0])
if err != nil { if err != nil {
return err return err
...@@ -645,7 +647,11 @@ Example: ...@@ -645,7 +647,11 @@ Example:
return err return err
} }
return mfs.Mv(nd.FilesRoot, src, dst) err = mfs.Mv(nd.FilesRoot, src, dst)
if err == nil && flush {
err = mfs.FlushPath(nd.FilesRoot, "/")
}
return err
}, },
} }
...@@ -908,11 +914,15 @@ Change the cid version or hash function of the root node of a given path. ...@@ -908,11 +914,15 @@ Change the cid version or hash function of the root node of a given path.
return err return err
} }
return updatePath(nd.FilesRoot, path, prefix, flush) err = updatePath(nd.FilesRoot, path, prefix)
if err == nil && flush {
err = mfs.FlushPath(nd.FilesRoot, path)
}
return err
}, },
} }
func updatePath(rt *mfs.Root, pth string, builder cid.Builder, flush bool) error { func updatePath(rt *mfs.Root, pth string, builder cid.Builder) error {
if builder == nil { if builder == nil {
return nil return nil
} }
...@@ -929,10 +939,6 @@ func updatePath(rt *mfs.Root, pth string, builder cid.Builder, flush bool) error ...@@ -929,10 +939,6 @@ func updatePath(rt *mfs.Root, pth string, builder cid.Builder, flush bool) error
return fmt.Errorf("can only update directories") return fmt.Errorf("can only update directories")
} }
if flush {
nd.Flush()
}
return nil return nil
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论