@@ -32,7 +32,9 @@ import (
32
32
repo "github.com/ipfs/go-ipfs/repo"
33
33
config "github.com/ipfs/go-ipfs/repo/config"
34
34
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
35
+
35
36
loggables "gx/ipfs/QmTMy4hVSY28DdwJ9kBz6y7q6MuioFzPcpM3Ma3aPjo1i3/go-libp2p-loggables"
37
+ "gx/ipfs/QmXuBJ7DR6k3rmUEKtvVMhwjmXDuJgXXPUt4LQXKBMsU93/go-os-helper"
36
38
)
37
39
38
40
// log is the command logger
@@ -591,18 +593,28 @@ func profileIfEnabled() (func(), error) {
591
593
return func () {}, nil
592
594
}
593
595
594
- var apiFileErrorFmt string = `Failed to parse %[1]s/api file.
596
+ var apiFileErrorFmt string = `Failed to parse ' %[1]s/api' file.
595
597
error: %[2]s
596
- If there is no daemon running, it is safe to delete it.
597
- You can do it with:
598
- ps aux | grep ipfs # check there is no ipfs daemon
599
- rm %[1]s/api
598
+ If you're sure go-ipfs isn't running, you can just delete it.
599
+ Otherwise check:
600
600
`
601
+ var checkIPFSUnixFmt = "\t ps aux | grep ipfs"
602
+ var checkIPFSWinFmt = "\t tasklist | findstr ipfs"
601
603
602
604
// getApiClient checks the repo, and the given options, checking for
603
605
// a running API service. if there is one, it returns a client.
604
606
// otherwise, it returns errApiNotRunning, or another error.
605
607
func getApiClient (repoPath , apiAddrStr string ) (cmdsHttp.Client , error ) {
608
+ var apiErrorFmt string
609
+ switch {
610
+ case osh .IsUnix ():
611
+ apiErrorFmt = apiFileErrorFmt + checkIPFSUnixFmt
612
+ case osh .IsWindows ():
613
+ apiErrorFmt = apiFileErrorFmt + checkIPFSWinFmt
614
+ default :
615
+ apiErrorFmt = apiFileErrorFmt
616
+ }
617
+
606
618
var addr ma.Multiaddr
607
619
var err error
608
620
if len (apiAddrStr ) != 0 {
@@ -617,11 +629,11 @@ func getApiClient(repoPath, apiAddrStr string) (cmdsHttp.Client, error) {
617
629
}
618
630
619
631
if err != nil {
620
- return nil , fmt .Errorf (apiFileErrorFmt , repoPath , err .Error ())
632
+ return nil , fmt .Errorf (apiErrorFmt , repoPath , err .Error ())
621
633
}
622
634
}
623
635
if len (addr .Protocols ()) == 0 {
624
- return nil , fmt .Errorf (apiFileErrorFmt , repoPath , "multiaddr doesn't provide any protocols" )
636
+ return nil , fmt .Errorf (apiErrorFmt , repoPath , "multiaddr doesn't provide any protocols" )
625
637
}
626
638
627
639
return apiClientForAddr (addr )
0 commit comments