Fixed issue creating row if does not exist

master
Jacob Windle 2019-02-13 16:16:37 -05:00
parent 5f577071ee
commit c6271ac7b6
1 changed files with 2 additions and 3 deletions

View File

@ -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.
})
}
})