From 6380787d7e0ba67146a0a9343675aac5c8c12aec Mon Sep 17 00:00:00 2001 From: DanyLE Date: Wed, 13 Mar 2024 18:20:46 +0100 Subject: [PATCH] fix: Change default silk db path to /var/silk --- configure.ac | 2 +- silkmvc/core/hook.lua | 2 +- silkmvc/core/sqlite.lua | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2f329bc..9ca8a16 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # initialise autoconf and set up some basic information about the program we’re packaging -AC_INIT([silk], [0.1.0], [xsang.le@gmail.com]) +AC_INIT([silk], [0.1.1], [xsang.le@gmail.com]) # We’re going to use automake for this project # [subdir-objects] if needed diff --git a/silkmvc/core/hook.lua b/silkmvc/core/hook.lua index 95c1b66..69bc859 100644 --- a/silkmvc/core/hook.lua +++ b/silkmvc/core/hook.lua @@ -4,7 +4,7 @@ math.randomseed(os.time()) __api__ = { apiroot = string.format("%s/lua", _SERVER["LIB_DIR"]), tmpdir = _SERVER["TMP_DIR"], - dbpath = _SERVER["DB_DIR"] + dbpath = "/var/silk" } -- root dir __ROOT__ = _SERVER["DOCUMENT_ROOT"] diff --git a/silkmvc/core/sqlite.lua b/silkmvc/core/sqlite.lua index 542b1bb..3264359 100644 --- a/silkmvc/core/sqlite.lua +++ b/silkmvc/core/sqlite.lua @@ -13,6 +13,13 @@ sqlite.getdb = function(name) LOG_ERROR("Invalid database name %s", name) return nil else + -- default db path is /var/silk/ + if not ulib.exists(__api__.dbpath) then + if not ulib.mkdir(__api__.dbpath) then + LOG_ERROR("Unable to create DB path: %s", __api__.dbpath) + return nil + end + end return sqlite.db(__api__.dbpath .. "/" .. name .. ".db") end end