diff --git a/src/index.js b/src/index.js index 87e0dd9ca..fa3e71842 100644 --- a/src/index.js +++ b/src/index.js @@ -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')