This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,21 @@ module.exports = (self) => {
49
49
50
50
if ( doInit ) {
51
51
self . log ( 'boot:doInit' )
52
- tasks . push ( ( cb ) => self . init ( initOptions , cb ) )
52
+ tasks . push ( ( cb ) => {
53
+ console . log ( 'Doing init' )
54
+ self . _repo . exists ( ( err , exists ) => {
55
+ if ( err ) cb ( err )
56
+ console . log ( 'exists' , err , exists )
57
+ if ( exists ) {
58
+ cb ( null , true )
59
+ } else {
60
+ self . init ( initOptions , ( err , res ) => {
61
+ console . log ( 'init' , err , res )
62
+ cb ( err , res )
63
+ } )
64
+ }
65
+ } )
66
+ } )
53
67
next ( null , true )
54
68
} else if ( ! repoOpen ) {
55
69
self . _repo . exists ( next )
Original file line number Diff line number Diff line change @@ -203,4 +203,19 @@ describe('create node', () => {
203
203
( cb ) => node . stop ( cb )
204
204
] , done )
205
205
} )
206
+
207
+ it ( 'can start node twice without crash' , ( done ) => {
208
+ const repo = createTempRepo ( )
209
+ let node = new IPFS ( { repo, config : { Bootstrap : [ ] } } )
210
+ series ( [
211
+ ( cb ) => node . once ( 'start' , cb ) ,
212
+ ( cb ) => node . stop ( cb ) ,
213
+ ( cb ) => {
214
+ node = new IPFS ( { repo, config : { Bootstrap : [ ] } } )
215
+ node . on ( 'error' , cb )
216
+ node . once ( 'start' , cb )
217
+ } ,
218
+ ( cb ) => node . stop ( cb )
219
+ ] , done )
220
+ } )
206
221
} )
You can’t perform that action at this time.
0 commit comments