Skip to content

Commit

Permalink
Merge pull request #7753 from ipfs/fix/dag-import-export-coreapi
Browse files Browse the repository at this point in the history
fix: ipfs dag export uses the CoreAPI and respects the offline flag
  • Loading branch information
aschmahmann authored Nov 24, 2020
2 parents 574702b + 9c5304a commit 6e82b53
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions core/commands/dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
)
}

node, err := cmdenv.GetNode(env)
api, err := cmdenv.GetApi(env, req)
if err != nil {
return err
}
Expand Down Expand Up @@ -588,7 +588,7 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
req.Context,
mdag.NewSession(
req.Context,
node.DAG,
api.Dag(),
),
[]cid.Cid{c},
pipeW,
Expand All @@ -606,9 +606,16 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.

// minimal user friendliness
if err != nil &&
!node.IsOnline &&
err == ipld.ErrNotFound {
err = fmt.Errorf("%s (currently offline, perhaps retry after attaching to the network)", err)
explicitOffline, _ := req.Options["offline"].(bool)
if explicitOffline {
err = fmt.Errorf("%s (currently offline, perhaps retry without the offline flag)", err)
} else {
node, envErr := cmdenv.GetNode(env)
if envErr == nil && !node.IsOnline {
err = fmt.Errorf("%s (currently offline, perhaps retry after attaching to the network)", err)
}
}
}

return err
Expand Down

0 comments on commit 6e82b53

Please sign in to comment.