Skip to content

Commit de98150

Browse files
authored
fix: remove api file (fixes a bug when there are unexpected shutdowns)
2 parents fef0a51 + e30a68e commit de98150

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ function onStartDaemon (node) {
5757
// not to be exiting correctly, hence the file is not
5858
// removed.
5959
const lockPath = join(config.settingsStore.get('ipfsPath'), 'repo.lock')
60+
const apiPath = join(config.settingsStore.get('ipfsPath'), 'api')
6061

6162
if (fs.existsSync(lockPath)) {
6263
try {
6364
fs.unlinkSync(lockPath)
64-
fs.unlinkSync(join(config.settingsStore.get('ipfsPath'), 'api'))
6565
} catch (e) {
6666
debug('Could not remove lock. Daemon might be running.')
6767
}
6868
}
6969

70+
if (fs.existsSync(apiPath)) {
71+
try {
72+
fs.unlinkSync(apiPath)
73+
} catch (e) {
74+
debug('Could not remove API file. Daemon might be running.')
75+
}
76+
}
77+
7078
const flags = []
7179
if (config.settingsStore.get('dhtClient')) {
7280
flags.push('--routing=dhtclient')

0 commit comments

Comments
 (0)