Skip to content

Commit

Permalink
fix: remove api file (fixes a bug when there are unexpected shutdowns)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored Mar 22, 2018
2 parents fef0a51 + e30a68e commit de98150
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,24 @@ function onStartDaemon (node) {
// not to be exiting correctly, hence the file is not
// removed.
const lockPath = join(config.settingsStore.get('ipfsPath'), 'repo.lock')
const apiPath = join(config.settingsStore.get('ipfsPath'), 'api')

if (fs.existsSync(lockPath)) {
try {
fs.unlinkSync(lockPath)
fs.unlinkSync(join(config.settingsStore.get('ipfsPath'), 'api'))
} catch (e) {
debug('Could not remove lock. Daemon might be running.')
}
}

if (fs.existsSync(apiPath)) {
try {
fs.unlinkSync(apiPath)
} catch (e) {
debug('Could not remove API file. Daemon might be running.')
}
}

const flags = []
if (config.settingsStore.get('dhtClient')) {
flags.push('--routing=dhtclient')
Expand Down

0 comments on commit de98150

Please sign in to comment.