diff --git a/core/commands/profile.go b/core/commands/profile.go index a6893d4eb..66abf7cef 100644 --- a/core/commands/profile.go +++ b/core/commands/profile.go @@ -13,8 +13,6 @@ import ( "time" cmds "github.com/ipfs/go-ipfs-cmds" - "github.com/ipfs/go-ipfs/core" - "github.com/ipfs/go-ipfs/core/commands/cmdenv" "github.com/ipfs/go-ipfs/core/commands/e" ) @@ -40,14 +38,9 @@ var sysProfileCmd = &cmds.Command{ return fmt.Errorf("failed to parse CPU profile duration %q: %w", cpuProfileTimeStr, err) } - nd, err := cmdenv.GetNode(env) - if err != nil { - return err - } - r, w := io.Pipe() go func() { - _ = w.CloseWithError(writeProfiles(req.Context, nd, cpuProfileTime, w)) + _ = w.CloseWithError(writeProfiles(req.Context, cpuProfileTime, w)) }() return res.Emit(r) }, @@ -88,7 +81,7 @@ var sysProfileCmd = &cmds.Command{ }, } -func writeProfiles(ctx context.Context, nd *core.IpfsNode, cpuProfileTime time.Duration, w io.Writer) error { +func writeProfiles(ctx context.Context, cpuProfileTime time.Duration, w io.Writer) error { archive := zip.NewWriter(w) // Take some profiles. @@ -135,17 +128,16 @@ func writeProfiles(ctx context.Context, nd *core.IpfsNode, cpuProfileTime time.D } } - // Collect info + // Collect version info + // I'd use diag sysinfo, but that includes some more sensitive information + // (GOPATH, etc.). { - out, err := archive.Create("sysinfo.json") + out, err := archive.Create("version.json") if err != nil { return err } - info, err := getInfo(nd) - if err != nil { - return err - } - err = json.NewEncoder(out).Encode(info) + + err = json.NewEncoder(out).Encode(getVersionInfo()) if err != nil { return err } diff --git a/core/commands/version.go b/core/commands/version.go index a36935452..ecdda594b 100644 --- a/core/commands/version.go +++ b/core/commands/version.go @@ -28,6 +28,16 @@ const ( versionAllOptionName = "all" ) +func getVersionInfo() *VersionOutput { + return &VersionOutput{ + Version: version.CurrentVersionNumber, + Commit: version.CurrentCommit, + Repo: fmt.Sprint(fsrepo.RepoVersion), + System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here + Golang: runtime.Version(), + } +} + var VersionCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Show IPFS version information.", @@ -46,13 +56,7 @@ var VersionCmd = &cmds.Command{ // must be permitted to run before init Extra: CreateCmdExtras(SetDoesNotUseRepo(true), SetDoesNotUseConfigAsInput(true)), Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { - return cmds.EmitOnce(res, &VersionOutput{ - Version: version.CurrentVersionNumber, - Commit: version.CurrentCommit, - Repo: fmt.Sprint(fsrepo.RepoVersion), - System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here - Golang: runtime.Version(), - }) + return cmds.EmitOnce(res, getVersionInfo()) }, Encoders: cmds.EncoderMap{ cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, version *VersionOutput) error {