Skip to content

Commit

Permalink
fix(core): look for MFS root in local repo only
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis authored and lidel committed Jun 21, 2024
1 parent 11bfb3c commit 6d31769
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/node/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func Dag(bs blockservice.BlockService) format.DAGService {
}

// Files loads persisted MFS root
func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, error) {
func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.DAGService, bs blockstore.Blockstore) (*mfs.Root, error) {
dsk := datastore.NewKey("/local/filesroot")
pf := func(ctx context.Context, c cid.Cid) error {
rootDS := repo.Datastore()
Expand All @@ -172,17 +172,18 @@ func Files(mctx helpers.MetricsCtx, lc fx.Lifecycle, repo repo.Repo, dag format.
nd = unixfs.EmptyDirNode()
err := dag.Add(ctx, nd)
if err != nil {
return nil, fmt.Errorf("failure writing to dagstore: %s", err)
return nil, fmt.Errorf("failure writing filesroot to dagstore: %s", err)
}
case err == nil:
c, err := cid.Cast(val)
if err != nil {
return nil, err
}

rnd, err := dag.Get(ctx, c)
offineDag := merkledag.NewDAGService(blockservice.New(bs, offline.Exchange(bs)))
rnd, err := offineDag.Get(ctx, c)
if err != nil {
return nil, fmt.Errorf("error loading filesroot from DAG: %s", err)
return nil, fmt.Errorf("error loading filesroot from dagservice: %s", err)
}

pbnd, ok := rnd.(*merkledag.ProtoNode)
Expand Down

0 comments on commit 6d31769

Please sign in to comment.