Fixed issue creating row if does not exist
This commit is contained in:
parent
5f577071ee
commit
c6271ac7b6
@ -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.
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user