Skip to content

Commit b28773d

Browse files
masihrjan90
authored andcommitted
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.
1 parent 5a4d6a9 commit b28773d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cmd/lotus-shed/datastore.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ var datastoreClearCmd = &cli.Command{
133133
},
134134
ArgsUsage: "[namespace]",
135135
Action: func(cctx *cli.Context) (_err error) {
136-
if cctx.NArg() != 2 {
137-
return xerrors.Errorf("requires 2 arguments: the datastore prefix")
136+
if cctx.NArg() != 1 {
137+
return xerrors.Errorf("requires 1 argument: the datastore prefix")
138138
}
139139
namespace := cctx.Args().Get(0)
140140

@@ -157,7 +157,7 @@ var datastoreClearCmd = &cli.Command{
157157
}
158158
defer lr.Close() //nolint:errcheck
159159

160-
ds, err := lr.Datastore(cctx.Context, namespace)
160+
ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String())
161161
if err != nil {
162162
return err
163163
}
@@ -306,7 +306,7 @@ var datastoreExportCmd = &cli.Command{
306306
}
307307
defer lr.Close() //nolint:errcheck
308308

309-
ds, err := lr.Datastore(cctx.Context, namespace)
309+
ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String())
310310
if err != nil {
311311
return err
312312
}
@@ -389,7 +389,7 @@ var datastoreImportCmd = &cli.Command{
389389
}
390390
defer lr.Close() //nolint:errcheck
391391

392-
ds, err := lr.Datastore(cctx.Context, namespace)
392+
ds, err := lr.Datastore(cctx.Context, datastore.NewKey(namespace).String())
393393
if err != nil {
394394
return err
395395
}

0 commit comments

Comments
 (0)