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