From 6b8ad2daafc2e60de6e27400173251657c3ef4af Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 30 Jul 2015 11:34:24 -0400 Subject: More safety belts on CP DB open --- etc/inc/captiveportal.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'etc/inc') diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc index 460263d..baf8bee 100644 --- a/etc/inc/captiveportal.inc +++ b/etc/inc/captiveportal.inc @@ -1414,6 +1414,19 @@ function captiveportal_opendb() { "CREATE INDEX IF NOT EXISTS ip ON captiveportal (ip); " . "CREATE INDEX IF NOT EXISTS starttime ON captiveportal (allow_time)"; + try { + $DB = new SQLite3($db_path); + } catch (Exception $e) { + captiveportal_syslog("Could not open {$db_path} as an sqlite database for {$cpzone}. Error message: " . $e->getMessage() . " -- Trying again."); + unlink_if_exists($db_path); + try { + $DB = new SQLite3($db_path); + } catch (Exception $e) { + captiveportal_syslog("Still could not open {$db_path} as an sqlite database for {$cpzone}. Error message: " . $e->getMessage() . " -- Remove the database file manually and ensure there is enough free space."); + return; + } + } + $DB = new SQLite3($db_path); if (!$DB) { captiveportal_syslog("Could not open {$db_path} as an sqlite database for {$cpzone}. Error message: {$DB->lastErrorMsg()}. Trying again."); -- cgit v1.1