-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
abb1a15
to
5821376
Compare
There was a problem hiding this 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]", |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() | ||
} |
There was a problem hiding this comment.
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?
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) | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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).
(also makes the
info all
a bit more robust)