Added: data integrity check

check for orphaned active ban records when mod loads and log them in the debug text file
master
shivajiva101 2021-12-10 01:08:49 +00:00 committed by GitHub
parent 440000d82b
commit d5bd6e255b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -1437,6 +1437,25 @@ local function process_expired_bans()
end
process_expired_bans() -- trigger on mod load
local function data_integrity_check()
local r, q = {}
minetest.log("action", "[sban] Data integrity check...")
q = [[SELECT
active.id,
active.name,
active.source,
active.created,
active.reason
FROM active
LEFT JOIN name ON name.id = active.id
WHERE name.id IS NULL;]]
for row in db:nrows(q) do
minetest.log("action", ([[[sban] id: %i %s %s %s %s is orphaned!]]
):format(row.id, row.name, row.source, hrdf(row.created), row.reason))
end
end
data_integrity_check() -- check for orphaned ban records!
local function clean_join_cache(name)
local ts = os.time()
local TTL = 10 -- ttl in seconds