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

shed command to unpack miner info dumps #5800

Merged
merged 3 commits into from
Mar 12, 2021
Merged

shed command to unpack miner info dumps #5800

merged 3 commits into from
Mar 12, 2021

Conversation

magik6k
Copy link
Contributor

@magik6k magik6k commented Mar 12, 2021

(also makes the info all a bit more robust)

@magik6k magik6k force-pushed the feat/allinfo-utils branch from abb1a15 to 5821376 Compare March 12, 2021 14:56
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments but nothing important/blocking.

var minerUnpackInfoCmd = &cli.Command{
Name: "unpack-info",
Usage: "unpack miner info all dump",
ArgsUsage: "[allinfo.txt] [dir]",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: call dir output direcctory (i.e., make it clear that this is the output).


if strings.HasPrefix(sl, "#") {
if strings.Contains(sl, "..") {
return xerrors.Errorf("bad name %s", sl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we trying to prevent directory traversal? (maybe a comment)

if err == io.EOF {
if outf != nil {
return outf.Close()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe return an explicit "we did nothing" error?

Comment on lines +104 to +109
if _, err := outf.Write(l); err != nil {
return xerrors.Errorf("write line: %w", err)
}
if _, err := outf.Write([]byte("\n")); err != nil {
return xerrors.Errorf("write line end: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fmt.Fprintln(outf, l) is a bit nicer.

@@ -35,88 +35,88 @@ var infoAllCmd = &cli.Command{

fmt.Println("#: Version")
if err := lcli.VersionCmd.Action(cctx); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to annotate these errors with what failed (even just a line number).

@magik6k magik6k merged commit 09e78a0 into master Mar 12, 2021
@magik6k magik6k deleted the feat/allinfo-utils branch March 12, 2021 18:02
@magik6k magik6k mentioned this pull request Apr 13, 2021
69 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants