From d58d6886314fc7790292afe6efacd433f2479b31 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Wed, 13 Nov 2024 12:47:19 +0700 Subject: [PATCH] Fix minor bugs in lotus shed datastore subcommand (#12694) * Use consistent pattern to pick `namespace`: the cleaned datastore key vs. direct user input. This way `metadata` for example would work consistently. Otherwise, `clear`, `export` and `import` wont work unless `/metadata` is specified. * Fix minor bug on number of arguments required for `clear` command. --- cmd/lotus-shed/datastore.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/lotus-shed/datastore.go b/cmd/lotus-shed/datastore.go index ad68145852..3c7d1f9831 100644 --- a/cmd/lotus-shed/datastore.go +++ b/cmd/lotus-shed/datastore.go @@ -133,8 +133,8 @@ var datastoreClearCmd = &cli.Command{ }, ArgsUsage: "[namespace]", Action: func(cctx *cli.Context) (_err error) { - if cctx.NArg() != 2 { - return xerrors.Errorf("requires 2 arguments: the datastore prefix") + if cctx.NArg() != 1 { + return xerrors.Errorf("requires 1 argument: the datastore prefix") } namespace := cctx.Args().Get(0) @@ -157,7 +157,7 @@ var datastoreClearCmd = &cli.Command{ } defer lr.Close() //nolint:errcheck - ds, err := lr.Datastore(cctx.Context, namespace) + ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String()) if err != nil { return err } @@ -306,7 +306,7 @@ var datastoreExportCmd = &cli.Command{ } defer lr.Close() //nolint:errcheck - ds, err := lr.Datastore(cctx.Context, namespace) + ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String()) if err != nil { return err } @@ -389,7 +389,7 @@ var datastoreImportCmd = &cli.Command{ } defer lr.Close() //nolint:errcheck - ds, err := lr.Datastore(cctx.Context, namespace) + ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String()) if err != nil { return err }