Skip to content

Commit

Permalink
fix(actions.ResolveDatasetRef): temp fix to keep incomplete ref respo…
Browse files Browse the repository at this point in the history
…nses from resolve
  • Loading branch information
b5 committed Dec 12, 2018
1 parent 2c4396e commit b284228
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion actions/dataset_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/qri-io/qri/p2p"
"github.com/qri-io/qri/repo"
"github.com/qri-io/qri/repo/profile"
"github.com/qri-io/registry"
)

// ResolveDatasetRef uses a node to complete the missing pieces of a dataset
Expand Down Expand Up @@ -38,6 +39,7 @@ func ResolveDatasetRef(node *p2p.QriNode, ref *repo.DatasetRef) (local bool, err
Peername: ref.Peername,
Name: ref.Name,
ProfileID: ref.ProfileID,
Path: ref.Path,
}

go func(ref *repo.DatasetRef) {
Expand All @@ -46,7 +48,8 @@ func ResolveDatasetRef(node *p2p.QriNode, ref *repo.DatasetRef) (local bool, err
responses <- res
}()

if ds, err := rc.GetDataset(ref.Peername, ref.Name, ref.ProfileID.String(), ref.Path); err == nil {
var ds *registry.Dataset
if ds, res.Error = rc.GetDataset(ref.Peername, ref.Name, ref.ProfileID.String(), ref.Path); res.Error == nil {
// Commit author is required to resolve ref
if ds.Commit != nil && ds.Commit.Author != nil {
ref.Peername = ds.Peername
Expand All @@ -63,6 +66,10 @@ func ResolveDatasetRef(node *p2p.QriNode, ref *repo.DatasetRef) (local bool, err
tasks++
go func() {
err := node.ResolveDatasetRef(ref)
log.Debugf("p2p ref res: %s", ref)
if !ref.Complete() && err == nil {
err = fmt.Errorf("p2p network responded with incomplete reference")
}
responses <- response{Ref: ref, Error: err}
}()
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/resolve_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (n *QriNode) handleResolveDatasetRef(ws *WrappedStream, msg Message) (hangu
}
res := msg

if err := repo.CanonicalizeDatasetRef(n.Repo, dsr); err == nil {
if err := repo.CanonicalizeDatasetRef(n.Repo, dsr); err == nil && dsr.Complete() {
res, err = msg.UpdateJSON(dsr)
if err != nil {
log.Debug(err.Error())
Expand Down

0 comments on commit b284228

Please sign in to comment.