-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
cmd: validate repo/api file and print nicer error message #3219
Conversation
if apiAddrStr == "" { | ||
var err error | ||
if apiAddrStr, err = fsrepo.APIAddr(repoPath); err != nil { | ||
efmt := fmt.Sprintf("failed to parse %[1]s/api file.\n\terror: %%s\n"+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets make this a multiline string constant somewhere
385b9cf
to
7c8a43d
Compare
Updated |
7c8a43d
to
928b832
Compare
Updated once more. |
error: %[2]s | ||
If there is no daemon running, it is safe to delete it. | ||
You can do it with: | ||
ps aux | grep ipfs # check there is no ipfs daemon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows that would be tasklist | findstr ipfs
, alternatively you can refer people to the Task Manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @djdv, I think something like this works:
If you're sure go-ipfs isn't running, you can just delete it.
Otherwise check:
ps aux | grep ipfs # on Linux and OSX
tasklist | findstr ipfs # on Windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also generate this message in an init
function where we can do a switch on runtime.GOOS
928b832
to
b1805a7
Compare
} | ||
|
||
s := string(buf[:n]) | ||
s = strings.TrimSpace(s) | ||
return s, nil | ||
m, err := ma.NewMultiaddr(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just return ma.NewMultiaddr(s)
here
@Kubuxu status update? |
I remember looking for a lib that we have already imported that included helpers for checking OSes, and then I did something else. |
a38e5cd
to
c4542cc
Compare
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple comments, then LGTM
return nil, fmt.Errorf(apiErrorFmt, repoPath, err.Error()) | ||
} | ||
} | ||
if len(addr.Protocols()) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this ever happen from a passed in apiAddrStr
? We don't want to accidentally tell the user about an api file if theyre manually specifying the address
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens when for some reason the API File is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, But theres no possible way we can end up with that scenario if the user passes in an api addr with --api
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea that is why I added check in 7512eb9
@@ -32,7 +25,14 @@ import ( | |||
repo "github.com/ipfs/go-ipfs/repo" | |||
config "github.com/ipfs/go-ipfs/repo/config" | |||
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo" | |||
|
|||
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" | |||
"gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the package name and the directory name arent the same, lets add osh
to name this import.
82dde0d
to
60195f0
Compare
Last commit should address it. |
3b89cf4
to
7512eb9
Compare
"author": "Kubuxu", | ||
"hash": "QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93", | ||
"name": "go-os-helper", | ||
"version": "0.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, look at that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what am i looking at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ok, not it is good. Just a second ago GH wasn't showing the bracket that is bellow this line.
@Kubuxu wanna rebase this and make sure the tests pass? |
7512eb9
to
3199047
Compare
Rebased. |
5865975
to
6068da7
Compare
Recreated it from ground 0 (easier than resolving conflicts in import section). |
6068da7
to
022846e
Compare
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
022846e
to
1e3b4ae
Compare
@whyrusleeping should be good for merge right now |
Resolves #3191
License: MIT
Signed-off-by: Jakub Sztandera kubuxu@protonmail.ch