plumb contexts in lotus-shed

This commit is contained in:
vyzo 2021-12-13 14:35:24 +02:00 committed by Jennifer Wang
parent 074f3850d8
commit 289ea3d33f
6 changed files with 13 additions and 12 deletions

View File

@ -83,7 +83,7 @@ var datastoreListCmd = &cli.Command{
genc := cctx.String("get-enc")
q, err := ds.Query(dsq.Query{
q, err := ds.Query(context.Background(), dsq.Query{
Prefix: datastore.NewKey(cctx.Args().Get(1)).String(),
KeysOnly: genc == "",
})
@ -147,7 +147,7 @@ var datastoreGetCmd = &cli.Command{
return err
}
val, err := ds.Get(datastore.NewKey(cctx.Args().Get(1)))
val, err := ds.Get(context.Background(), datastore.NewKey(cctx.Args().Get(1)))
if err != nil {
return xerrors.Errorf("get: %w", err)
}

View File

@ -93,7 +93,7 @@ var exportChainCmd = &cli.Command{
cs := store.NewChainStore(bs, bs, mds, nil, nil)
defer cs.Close() //nolint:errcheck
if err := cs.Load(); err != nil {
if err := cs.Load(context.Background()); err != nil {
return err
}
@ -110,7 +110,7 @@ var exportChainCmd = &cli.Command{
tsk := types.NewTipSetKey(cids...)
selts, err := cs.LoadTipSet(tsk)
selts, err := cs.LoadTipSet(context.Background(), tsk)
if err != nil {
return xerrors.Errorf("loading tipset: %w", err)
}

View File

@ -82,7 +82,7 @@ var importCarCmd = &cli.Command{
return err
case nil:
fmt.Printf("\r%s", blk.Cid())
if err := bs.Put(blk); err != nil {
if err := bs.Put(context.Background(), blk); err != nil {
if err := f.Close(); err != nil {
return err
}
@ -146,7 +146,7 @@ var importObjectCmd = &cli.Command{
return err
}
if err := bs.Put(blk); err != nil {
if err := bs.Put(context.Background(), blk); err != nil {
return err
}

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"fmt"
"os"
"path"
@ -198,7 +199,7 @@ var marketExportDatastoreCmd = &cli.Command{
}
// Write the backup to the file
if err := bds.Backup(out); err != nil {
if err := bds.Backup(context.Background(), out); err != nil {
if cerr := out.Close(); cerr != nil {
log.Errorw("error closing backup file while handling backup error", "closeErr", cerr, "backupErr", err)
}
@ -215,7 +216,7 @@ var marketExportDatastoreCmd = &cli.Command{
}
func exportPrefix(prefix string, ds datastore.Batching, backupDs datastore.Batching) error {
q, err := ds.Query(dsq.Query{
q, err := ds.Query(context.Background(), dsq.Query{
Prefix: prefix,
})
if err != nil {
@ -225,7 +226,7 @@ func exportPrefix(prefix string, ds datastore.Batching, backupDs datastore.Batch
for res := range q.Next() {
fmt.Println("Exporting key " + res.Key)
err := backupDs.Put(datastore.NewKey(res.Key), res.Value)
err := backupDs.Put(context.Background(), datastore.NewKey(res.Key), res.Value)
if err != nil {
return xerrors.Errorf("putting %s to backup datastore: %w", res.Key, err)
}

View File

@ -171,7 +171,7 @@ var stateTreePruneCmd = &cli.Command{
cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil)
defer cs.Close() //nolint:errcheck
if err := cs.Load(); err != nil {
if err := cs.Load(context.Background()); err != nil {
return fmt.Errorf("loading chainstore: %w", err)
}

View File

@ -331,7 +331,7 @@ func deleteSplitstoreKeys(lr repo.LockedRepo) error {
}
var keys []datastore.Key
res, err := ds.Query(query.Query{Prefix: "/splitstore"})
res, err := ds.Query(context.Background(), query.Query{Prefix: "/splitstore"})
if err != nil {
return xerrors.Errorf("error querying datastore for splitstore keys: %w", err)
}
@ -346,7 +346,7 @@ func deleteSplitstoreKeys(lr repo.LockedRepo) error {
for _, k := range keys {
fmt.Printf("deleting %s from datastore...\n", k)
err = ds.Delete(k)
err = ds.Delete(context.Background(), k)
if err != nil {
return xerrors.Errorf("error deleting key %s from datastore: %w", k, err)
}