fixed missing cache issue
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Samuel Philipp 2020-02-27 20:41:56 +01:00
parent a2677ef2a3
commit b3d24f98ba

View file

@ -9,7 +9,9 @@ const nmap = require('libnmap');
let cachePath = path.resolve("./data/cache.json"); let cachePath = path.resolve("./data/cache.json");
const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {}; const cache = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath, {encoding: "utf8"})) : {};
// delete cache file to remove orphaned cache values // delete cache file to remove orphaned cache values
if (fs.existsSync(cachePath)) {
fs.unlinkSync(cachePath); fs.unlinkSync(cachePath);
}
process.on('SIGINT', () => { process.on('SIGINT', () => {
fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"}); fs.writeFileSync(cachePath, JSON.stringify(cache), {encoding: "utf8"});