From 8c893b4a32590a2a90f6715bde11660498406aaf Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 17 Sep 2023 17:34:27 +0700 Subject: [PATCH] Fixed cache directory auto-creating with SQLite (#247) * Fixed cache directory auto-creating with SQLite * Update CHANGELOG.md --- CHANGELOG.md | 1 + library/includes/cache/sqlite.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3244d79f..fa8ebb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release v2.1.5-2023.09 🎉 +- Fixed cache directory auto-creating with SQLite [\#247](https://github.com/torrentpier/torrentpier-lts/pull/247) ([belomaxorka](https://github.com/belomaxorka)) - Minor improvements [\#245](https://github.com/torrentpier/torrentpier-lts/pull/245), [\#246](https://github.com/torrentpier/torrentpier-lts/pull/246) ([belomaxorka](https://github.com/belomaxorka)) ## [v2.1.5-2023.08-HotFix](https://github.com/torrentpier/torrentpier-lts/tree/v2.1.5-2023.08-HotFix) (2023-09-17) diff --git a/library/includes/cache/sqlite.php b/library/includes/cache/sqlite.php index 4e88a8e2..f9788f22 100644 --- a/library/includes/cache/sqlite.php +++ b/library/includes/cache/sqlite.php @@ -142,6 +142,24 @@ class sqlite_common extends cache_common { $this->cfg = array_merge($this->cfg, $cfg); $this->dbg_enabled = sql_dbg_enabled(); + + // Creates filecache dir + $db_dir = dirname($this->cfg['db_file_path']); + + if (!is_dir($db_dir)) + { + if (!bb_mkdir($db_dir)) + { + $create_error = "Cannot create {$this->engine} cache dir: $db_dir"; + + if (DBG_LOG) + { + dbg_log($create_error, "{$this->engine}-CACHE-mkdir-FAIL_" . time()); + } + + die($create_error); + } + } } function connect () @@ -300,4 +318,4 @@ class sqlite_common extends cache_common { if (error_reporting()) trigger_error($msg, E_USER_ERROR); } -} \ No newline at end of file +}