fix: ipfs dag export uses the CoreAPI and respects the offline flag
Adin Schmahmann committed
Nov 4, 2020 at 21:14 UTC
9c5304a21de66fa8f1eae715e8218396b31d18d6
1 file changed
+11
-4
core/commands/dag/dag.go
+11
-4
@@ -550,7 +550,7 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
550
)
551
}
552
553
- node, err := cmdenv.GetNode(env)
553
+ api, err := cmdenv.GetApi(env, req)
554
if err != nil {
555
return err
556
}
@@ -588,7 +588,7 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
588
req.Context,
589
mdag.NewSession(
590
req.Context,
591
- node.DAG,
591
+ api.Dag(),
592
),
593
[]cid.Cid{c},
594
pipeW,
@@ -606,9 +606,16 @@ The output of blocks happens in strict DAG-traversal, first-seen, order.
606
607
// minimal user friendliness
608
if err != nil &&
609
- !node.IsOnline &&
609
err == ipld.ErrNotFound {
611
- err = fmt.Errorf("%s (currently offline, perhaps retry after attaching to the network)", err)
610
+ explicitOffline, _ := req.Options["offline"].(bool)
611
+ if explicitOffline {
612
+ err = fmt.Errorf("%s (currently offline, perhaps retry without the offline flag)", err)
613
+ } else {
614
+ node, envErr := cmdenv.GetNode(env)
615
+ if envErr == nil && !node.IsOnline {
616
+ err = fmt.Errorf("%s (currently offline, perhaps retry after attaching to the network)", err)
617
+ }
618
+ }
619
}
620
621
return err