Fixed issue creating row if does not exist

This commit is contained in:
Jacob Windle 2019-02-13 16:16:37 -05:00
parent 5f577071ee
commit c6271ac7b6

View File

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