From c6271ac7b6f8f5cc4b8d5c5e66d8496e0e7f7601 Mon Sep 17 00:00:00 2001 From: jaketothepast Date: Wed, 13 Feb 2019 16:16:37 -0500 Subject: [PATCH] Fixed issue creating row if does not exist --- lib/db.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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. }) } })