Merge pull request #7688 from filecoin-project/chore/partret_cleanup_comment_and_flow
Cleanup partial retrieval codepaths ( zero functional changes )
This commit is contained in:
commit
77d75b7739
@ -220,8 +220,10 @@ type ExportRef struct {
|
|||||||
Root cid.Cid
|
Root cid.Cid
|
||||||
|
|
||||||
// DAGs array specifies a list of DAGs to export
|
// DAGs array specifies a list of DAGs to export
|
||||||
// - If exporting into a car file, defines car roots
|
// - If exporting into unixfs files, only one DAG is supported, DataSelector is only used to find the targeted root node
|
||||||
// - If exporting into unixfs files, only one DAG is supported, DataSelector is only used to find the root node
|
// - If exporting into a car file
|
||||||
|
// - When exactly one text-path DataSelector is specified exports the subgraph and its full merkle-path from the original root
|
||||||
|
// - Otherwise ( multiple paths and/or JSON selector specs) determines each individual subroot and exports the subtrees as a multi-root car
|
||||||
// - When not specified defaults to a single DAG:
|
// - When not specified defaults to a single DAG:
|
||||||
// - Data - the entire DAG: `{"R":{"l":{"none":{}},":>":{"a":{">":{"@":{}}}}}}`
|
// - Data - the entire DAG: `{"R":{"l":{"none":{}},":>":{"a":{">":{"@":{}}}}}}`
|
||||||
DAGs []DagSpec
|
DAGs []DagSpec
|
||||||
|
@ -1038,8 +1038,18 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
|
|||||||
out := make([]dagSpec, len(dsp))
|
out := make([]dagSpec, len(dsp))
|
||||||
for i, spec := range dsp {
|
for i, spec := range dsp {
|
||||||
|
|
||||||
// if a selector is specified, find it's root node
|
if spec.DataSelector == nil {
|
||||||
if spec.DataSelector != nil {
|
return nil, xerrors.Errorf("invalid DagSpec at position %d: `DataSelector` can not be nil", i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// reify selector
|
||||||
|
var err error
|
||||||
|
out[i].selector, err = getDataSelector(spec.DataSelector)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// find the pointed-at root node within the containing ds
|
||||||
var rsn ipld.Node
|
var rsn ipld.Node
|
||||||
|
|
||||||
if strings.HasPrefix(string(*spec.DataSelector), "{") {
|
if strings.HasPrefix(string(*spec.DataSelector), "{") {
|
||||||
@ -1054,9 +1064,7 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newRoot cid.Cid
|
var newRoot cid.Cid
|
||||||
|
|
||||||
var errHalt = errors.New("halt walk")
|
var errHalt = errors.New("halt walk")
|
||||||
|
|
||||||
if err := utils.TraverseDag(
|
if err := utils.TraverseDag(
|
||||||
ctx,
|
ctx,
|
||||||
ds,
|
ds,
|
||||||
@ -1096,15 +1104,6 @@ func parseDagSpec(ctx context.Context, root cid.Cid, dsp []api.DagSpec, ds forma
|
|||||||
out[i].root = newRoot
|
out[i].root = newRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
if spec.DataSelector != nil {
|
|
||||||
var err error
|
|
||||||
out[i].selector, err = getDataSelector(spec.DataSelector)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user