Skip to content

Commit 15257dc

Browse files
committed
feat: do not cleanup api/repo.lock
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
1 parent 24cbe44 commit 15257dc

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

src/utils/daemon.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import IPFSFactory from 'ipfsd-ctl'
2-
import { join } from 'path'
32
import fs from 'fs-extra'
4-
import logger from './logger'
53

64
export default async function createDaemon (opts) {
75
opts.type = opts.type || 'go'
@@ -14,17 +12,10 @@ export default async function createDaemon (opts) {
1412
}
1513

1614
const init = !(await fs.pathExists(opts.path)) || fs.readdirSync(opts.path).length === 0
17-
18-
if (!init) {
19-
await cleanLocks(opts.path)
20-
}
21-
2215
const factory = IPFSFactory.create({ type: opts.type })
2316

2417
const ipfsd = await new Promise((resolve, reject) => {
2518
factory.spawn({
26-
init: false,
27-
start: false,
2819
disposable: false,
2920
defaultAddrs: true,
3021
repoPath: opts.path
@@ -65,28 +56,3 @@ export default async function createDaemon (opts) {
6556

6657
return ipfsd
6758
}
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

Comments
 (0)