diff --git a/lib/cache.js b/lib/cache.js index d8683003..426104ae 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -2,6 +2,15 @@ var levelup = require('levelup'); var ttl = require('level-ttl'); var spaces = require('level-spaces'); var nconf = require('nconf'); +var fs = require('fs'); +var rimraf = require('rimraf'); +var path = require('path'); + +var db_path = nconf.get('CACHE_FILE'); + +if (fs.existsSync(path.join(db_path, 'LOCK'))) { + rimraf.sync(db_path); +} var db = levelup(nconf.get('CACHE_FILE')); diff --git a/package.json b/package.json index 6c8d010c..d50eb284 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "passport-windowsauth": "~0.4.1", "randomstring": "~1.0.3", "request": "~2.16.6", + "rimraf": "~2.5.2", "selfsigned": "~1.2.0", "stream-rotate": "0.0.4", "thumbprint": "0.0.1",