Skip to content

Commit

Permalink
Merge pull request #8426 from filecoin-project/feat/multi-vlog2car
Browse files Browse the repository at this point in the history
feat: shed: Multi-file vlog2car
  • Loading branch information
magik6k authored Apr 2, 2022
2 parents e74e569 + 9a34f58 commit a40381a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/lotus-shed/datastore-vlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/dgraph-io/badger/v2/y"
block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-cid"
"github.com/mitchellh/go-homedir"
"github.com/multiformats/go-base32"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
Expand All @@ -23,11 +24,6 @@ var datastoreVlog2CarCmd = &cli.Command{
Name: "vlog2car",
Usage: "convert badger blockstore .vlog to .car",
Flags: []cli.Flag{
&cli.PathFlag{
Name: "vlog",
Usage: "vlog file",
Required: true,
},
&cli.PathFlag{
Name: "car",
Usage: "out car file name (no .car)",
Expand All @@ -39,10 +35,11 @@ var datastoreVlog2CarCmd = &cli.Command{
Value: "/blocks/",
},
},
ArgsUsage: "[vlog...]",
Action: func(cctx *cli.Context) error {
ctx := cctx.Context

maxSz := uint64(1 << 20)
maxSz := uint64(31 << 30)

carb := &rawCarb{
max: maxSz,
Expand All @@ -53,11 +50,16 @@ var datastoreVlog2CarCmd = &cli.Command{
pref := cctx.String("key-prefix")
plen := len(pref)

{
for _, vlogPath := range cctx.Args().Slice() {
vlogPath, err := homedir.Expand(vlogPath)
if err != nil {
return xerrors.Errorf("expand vlog path: %w", err)
}

// NOTE: Some bits of code in this code block come from https://github.com/dgraph-io/badger, which is licensed
// under Apache 2.0; See https://github.com/dgraph-io/badger/blob/master/LICENSE

vf, err := os.Open(cctx.Path("vlog"))
vf, err := os.Open(vlogPath)
if err != nil {
return xerrors.Errorf("open vlog file: %w", err)
}
Expand Down

0 comments on commit a40381a

Please sign in to comment.