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

Make non recursive resolve print the result #2283

Merged
merged 1 commit into from
Apr 13, 2016

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Feb 2, 2016

Currently it prints out error message but should just print
the intermediate result as it is what we expect.

License: MIT
Signed-off-by: Jakub Sztandera kubuxu@gmail.com

@rht
Copy link
Contributor

rht commented Feb 2, 2016

I think this should be the default behavior of the function https://github.com/ipfs/go-ipfs/blob/5274ad9e8f71bd0b022863622c680ed07710d76f/namesys/namesys.go#L59 when the depth is 1, instead of a ux tweak that is only in core/commands.

@Kubuxu
Copy link
Member Author

Kubuxu commented Feb 2, 2016

It is tested with it returning value and error so I assumed it is intentional. If there is no error returned then you can't know if it was full resolution or not via API, via CLI it is more important to show significant result than to error out (as only one of them can be shown). In API you can send both and if someone is setting low recursion limit (1) he just might want to check what was the result.

(Travis fail is not connected).

@rht
Copy link
Contributor

rht commented Feb 2, 2016

https://github.com/ipfs/go-ipfs/blob/5274ad9e8f71bd0b022863622c680ed07710d76f/namesys/base.go#L32 assumes that depth begins at > 1, and hence the err. The fix should be to not return the err when the depth begins at 1 (nonrecursive) for both the API/CLI and library interface.

edit: s|API and CLI|API/CLI and library interface|

@Kubuxu
Copy link
Member Author

Kubuxu commented Feb 2, 2016

As I said, IMHO returning error with the result is good idea in API as it gives more information (you know that resolution hasn't finish. So I see no reason to change the API only CLI (as it can show result or error) should show result when non-recursive resolution is requested.

@rht
Copy link
Contributor

rht commented Feb 2, 2016

If the returned path of a nonrecursive resolve is an ipns path, then this is sufficient information that the resolve hasn't reached an ipfs path yet. An error message is not necessary in this case, which is the fix proposed in this PR, but is only done for the CLI and API. While I think it should also be the case for any libraries calling the namesys.ResolveN.

@Kubuxu
Copy link
Member Author

Kubuxu commented Feb 2, 2016

The namesys/base.go should stay the same (it is part of the recursion) place to change it (if we want to change the API) would be namesys/namesys.go. Question is: Do we want to change the API?

cc @whyrusleeping

@rht
Copy link
Contributor

rht commented Feb 2, 2016

Clarification: changing core/commands will also change the HTTP API behavior. Yet any libraries calling the namesys.ResolveN with depth=1 will still return the err. What I'm suggesting here is if the function itself should be changed so that library calls have the same behavior as the CLI/API.

@rht
Copy link
Contributor

rht commented Feb 2, 2016

I mean,

if depth == 1 {
    return ns.resolveOnce(ctx, name)
}

should precede https://github.com/ipfs/go-ipfs/blob/5274ad9e8f71bd0b022863622c680ed07710d76f/namesys/namesys.go#L59 so that any libraries using ns.ResolveN(ctx, name, 1) returns the same result as in CLI/API.

@Kubuxu
Copy link
Member Author

Kubuxu commented Feb 14, 2016

Rebased

@whyrusleeping
Copy link
Member

@Kubuxu rebase once more and i'll merge it, i promise!

Currently it prints out error message but should just print
the intermediate result as it is what we expect.

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@gmail.com>
@Kubuxu
Copy link
Member Author

Kubuxu commented Apr 13, 2016

Rebased.

@whyrusleeping whyrusleeping merged commit 94a53ac into ipfs:master Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants