changeset 5353:14b6397cd6de

mod_audit_status: Fix error on first start Fixes 'attempt to index a nil value' the first time this module is loaded, since there's no data yet.
author Kim Alvefur <zash@zash.se>
date Tue, 18 Apr 2023 21:48:31 +0200
parents f6577cdb1d91
children 39d59d857bfb
files mod_audit_status/mod_audit_status.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_audit_status/mod_audit_status.lua	Mon Apr 17 14:31:50 2023 +0100
+++ b/mod_audit_status/mod_audit_status.lua	Tue Apr 18 21:48:31 2023 +0200
@@ -11,7 +11,7 @@
 
 module:hook_global("server-started", function ()
 	local recorded_status = store:get();
-	if recorded_status.status == "started" then
+	if recorded_status and recorded_status.status == "started" then
 		module:audit(nil, "server-crashed", { timestamp = recorded_status.heartbeat });
 	end
 	module:audit(nil, "server-started");