diff --git a/lib/db.js b/lib/db.js index e237340..e89928e 100644 --- a/lib/db.js +++ b/lib/db.js @@ -54,10 +54,9 @@ exports.initializeDatabase = function() { // if (blockedData.hosts.length row['count(*)']) for (let host of blockedData.hosts) { db.get("select hostname from blocked_hosts where hostname = ?", [host], (err, row) => { - if (err !== null) { - db.run("insert into blocked_hosts (hostname) values (?)", [hostname]); + if (row === undefined) { + db.run("insert into blocked_hosts (hostname) values (?)", [host]); } - // TODO -- run a diff for whatever has been deleted from the config file. }) } })