File tree 2 files changed +53
-6
lines changed
2 files changed +53
-6
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import (
26
26
iconn "gx/ipfs/QmT6jBTqNKhhb8dbzCEMUNkGhm3RuRActcMhpShAHLpQtp/go-libp2p-interface-conn"
27
27
"gx/ipfs/QmVCNGTyD4EkvNYaAp253uMQ9Rjsjy2oGMvcdJJUoVRfja/go-multiaddr-net"
28
28
"gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus"
29
- util "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
30
29
pstore "gx/ipfs/Qme1g4e3m2SmdiSGGU3vSWmUStwUjc5oECnEriaK9Xa1HU/go-libp2p-peerstore"
31
30
)
32
31
@@ -227,11 +226,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
227
226
228
227
if initialize {
229
228
230
- // now, FileExists is our best method of detecting whether ipfs is
231
- // configured. Consider moving this into a config helper method
232
- // `IsInitialized` where the quality of the signal can be improved over
233
- // time, and many call-sites can benefit.
234
- if ! util .FileExists (req .InvocContext ().ConfigRoot ) {
229
+ if ! fsrepo .IsInitialized (req .InvocContext ().ConfigRoot ) {
235
230
err := initWithDefaults (os .Stdout , req .InvocContext ().ConfigRoot )
236
231
if err != nil {
237
232
res .SetError (err , cmds .ErrNormal )
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ #
3
+ # Copyright (c) 2014 Juan Batiz-Benet
4
+ # MIT Licensed; see the LICENSE file in this repository.
5
+ #
6
+
7
+ test_description=" Test daemon --init command"
8
+
9
+ . lib/test-lib.sh
10
+
11
+ # We don't want the normal test_init_ipfs but we need to make sure the
12
+ # IPFS_PATH is set correctly.
13
+ export IPFS_PATH=" $( pwd) /.ipfs"
14
+
15
+ # safety check since we will be removing the directory
16
+ if [ -e " $IPFS_PATH " ]; then
17
+ echo " $IPFS_PATH exists"
18
+ exit 1
19
+ fi
20
+
21
+ test_ipfs_daemon_init () {
22
+ # Doing it manually since we want to launch the daemon with an
23
+ # empty or non-existent REPO; the normal
24
+ # test_launch_ipfs_daemon does not work since it assumes the
25
+ # repo was created a particular way with regard to the API
26
+ # server.
27
+
28
+ test_expect_success " 'ipfs daemon --init' succeeds" '
29
+ ipfs daemon --init >actual_daemon 2>daemon_err &
30
+ IPFS_PID=$! &&
31
+ sleep 2 &&
32
+ if ! kill -0 $IPFS_PID; then cat daemon_err; exit 1; fi
33
+ '
34
+
35
+ test_expect_success " 'ipfs daemon' can be killed" '
36
+ test_kill_repeat_10_sec $IPFS_PID
37
+ '
38
+ }
39
+
40
+ test_expect_success " remove \$ IPFS_PATH dir" '
41
+ rm -rf "$IPFS_PATH"
42
+ '
43
+ test_ipfs_daemon_init
44
+
45
+ test_expect_success " create empty \$ IPFS_PATH dir" '
46
+ rm -rf "$IPFS_PATH"
47
+ mkdir "$IPFS_PATH"
48
+ '
49
+
50
+ test_ipfs_daemon_init
51
+
52
+ test_done
You can’t perform that action at this time.
0 commit comments