1
1
import IPFSFactory from 'ipfsd-ctl'
2
- import { join } from 'path'
3
2
import fs from 'fs-extra'
4
- import logger from './logger'
5
3
6
4
export default async function createDaemon ( opts ) {
7
5
opts . type = opts . type || 'go'
@@ -14,17 +12,10 @@ export default async function createDaemon (opts) {
14
12
}
15
13
16
14
const init = ! ( await fs . pathExists ( opts . path ) ) || fs . readdirSync ( opts . path ) . length === 0
17
-
18
- if ( ! init ) {
19
- await cleanLocks ( opts . path )
20
- }
21
-
22
15
const factory = IPFSFactory . create ( { type : opts . type } )
23
16
24
17
const ipfsd = await new Promise ( ( resolve , reject ) => {
25
18
factory . spawn ( {
26
- init : false ,
27
- start : false ,
28
19
disposable : false ,
29
20
defaultAddrs : true ,
30
21
repoPath : opts . path
@@ -65,28 +56,3 @@ export default async function createDaemon (opts) {
65
56
66
57
return ipfsd
67
58
}
68
-
69
- function cleanLocks ( path ) {
70
- // This fixes a bug on Windows, where the daemon seems
71
- // not to be exiting correctly, hence the file is not
72
- // removed.
73
- logger . info ( 'Cleaning repo.lock and api files' )
74
- const lockPath = join ( path , 'repo.lock' )
75
- const apiPath = join ( path , 'api' )
76
-
77
- if ( fs . existsSync ( lockPath ) ) {
78
- try {
79
- fs . unlinkSync ( lockPath )
80
- } catch ( _ ) {
81
- logger . warn ( 'Could not remove repo.lock. Daemon might be running' )
82
- }
83
- }
84
-
85
- if ( fs . existsSync ( apiPath ) ) {
86
- try {
87
- fs . unlinkSync ( apiPath )
88
- } catch ( _ ) {
89
- logger . warn ( 'Could not remove api. Daemon might be running' )
90
- }
91
- }
92
- }
0 commit comments