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 +27
-12
lines changed Expand file tree Collapse file tree 2 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -47,25 +47,25 @@ module.exports = (self) => {
47
47
48
48
const tasks = [ ]
49
49
50
- if ( doInit ) {
51
- self . log ( 'boot:doInit' )
52
- tasks . push ( ( cb ) => self . init ( initOptions , cb ) )
53
- next ( null , true )
54
- } else if ( ! repoOpen ) {
55
- self . _repo . exists ( next )
56
- }
50
+ self . _repo . exists ( ( err , repoExists ) => {
51
+ if ( err ) {
52
+ return done ( err )
53
+ }
54
+ if ( doInit && ! repoExists ) {
55
+ tasks . push ( ( cb ) => self . init ( initOptions , cb ) )
56
+ }
57
+ if ( repoExists ) {
58
+ tasks . push ( maybeOpenRepo )
59
+ }
60
+ next ( null , repoExists )
61
+ } )
57
62
58
63
function next ( err , hasRepo ) {
59
64
self . log ( 'boot:next' )
60
65
if ( err ) {
61
66
return done ( err )
62
67
}
63
68
64
- if ( hasRepo && ! doInit ) {
65
- self . log ( 'boot:maybeopenreop' )
66
- tasks . push ( maybeOpenRepo )
67
- }
68
-
69
69
if ( setConfig ) {
70
70
self . log ( 'boot:setConfig' )
71
71
if ( ! hasRepo ) {
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