From c04e0f442185b4d697da1b027d61f5a70fa8ff5e Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 16 Mar 2023 17:17:26 +0200 Subject: [PATCH] shed: expand homedir in repo path for msgindex tools --- cmd/lotus-shed/msgindex.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/lotus-shed/msgindex.go b/cmd/lotus-shed/msgindex.go index d2cb2cf3d..fae733bbe 100644 --- a/cmd/lotus-shed/msgindex.go +++ b/cmd/lotus-shed/msgindex.go @@ -7,6 +7,7 @@ import ( "github.com/ipfs/go-cid" _ "github.com/mattn/go-sqlite3" + "github.com/mitchellh/go-homedir" "github.com/urfave/cli/v2" "golang.org/x/xerrors" @@ -64,7 +65,12 @@ var msgindexBackfillCmd = &cli.Command{ } epochs := cctx.Int("epochs") - dbPath := path.Join(cctx.String("repo"), "sqlite", "msgindex.db") + basePath, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + dbPath := path.Join(basePath, "sqlite", "msgindex.db") db, err := sql.Open("sqlite3", dbPath) if err != nil { return err @@ -176,7 +182,12 @@ var msgindexPruneCmd = &cli.Command{ } } - dbPath := path.Join(cctx.String("repo"), "sqlite", "msgindex.db") + basePath, err := homedir.Expand(cctx.String("repo")) + if err != nil { + return err + } + + dbPath := path.Join(basePath, "sqlite", "msgindex.db") db, err := sql.Open("sqlite3", dbPath) if err != nil { return err