Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ipfs dag export uses the CoreAPI and respects the offline flag #7753

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Comment on lines 608 to 609
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there could be more errors that have nothing to do with being offline (e.g. datastore fetching errors, context cancellations, etc.) and that this was already here doesn't seem like it hurts.

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)
aschmahmann marked this conversation as resolved.
Show resolved Hide resolved
if envErr == nil && !node.IsOnline {
err = fmt.Errorf("%s (currently offline, perhaps retry after attaching to the network)", err)
}
}
}

return err
Expand Down