Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mfs: make sure to flush after mv and chcid #5936

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions core/commands/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,8 @@ Example:
return err
}

flush, _ := req.Options[filesFlushOptionName].(bool)

src, err := checkPath(req.Arguments[0])
if err != nil {
return err
Expand All @@ -645,7 +647,11 @@ Example:
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
},
}

Expand Down Expand Up @@ -908,11 +914,15 @@ Change the cid version or hash function of the root node of a given path.
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 {
return nil
}
Expand All @@ -929,10 +939,6 @@ func updatePath(rt *mfs.Root, pth string, builder cid.Builder, flush bool) error
return fmt.Errorf("can only update directories")
}

if flush {
nd.Flush()
}

return nil
}

Expand Down