A free, self-hostable news aggregator…
NFS-friendly is_writable() checks (#4780)
Alexandre Alapetite8864d514c82b
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.phpindex 675bd7def..f1588c7e1 100644--- a/app/Controllers/updateController.php+++ b/app/Controllers/updateController.php@@ -14,7 +14,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {public static function migrateToGitEdge() {$errorMessage = 'Error during git checkout to edge branch. Please change branch manually!';- if (!is_writable(FRESHRSS_PATH . '/.git/')) {+ if (!is_writable(FRESHRSS_PATH . '/.git/config')) {throw new Exception($errorMessage);}@@ -118,7 +118,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {if ($version == '') {$version = 'unknown';}- if (is_writable(FRESHRSS_PATH)) {+ if (touch(FRESHRSS_PATH . '/index.html')) {$this->view->update_to_apply = true;$this->view->message = array('status' => 'good',@@ -217,7 +217,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {}public function applyAction() {- if (!file_exists(UPDATE_FILENAME) || !is_writable(FRESHRSS_PATH) || Minz_Configuration::get('system')->disable_update) {+ if (Minz_Configuration::get('system')->disable_update || !file_exists(UPDATE_FILENAME) || !touch(FRESHRSS_PATH . '/index.html')) {Minz_Request::forward(array('c' => 'update'), true);}diff --git a/app/Utils/feverUtil.php b/app/Utils/feverUtil.phpindex a7d21dacb..277230ec2 100644--- a/app/Utils/feverUtil.php+++ b/app/Utils/feverUtil.php@@ -13,7 +13,7 @@ class FreshRSS_fever_Util {@mkdir(self::FEVER_PATH, 0770, true);}- $ok = is_writable(self::FEVER_PATH);+ $ok = touch(self::FEVER_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFSif (!$ok) {Minz_Log::error("Could not save Fever API credentials. The directory does not have write access.");}diff --git a/lib/lib_install.php b/lib/lib_install.phpindex 494ddc6dd..0204c90c9 100644--- a/lib/lib_install.php+++ b/lib/lib_install.php@@ -42,14 +42,14 @@ function checkRequirements($dbType = '') {$json = function_exists('json_encode');$mbstring = extension_loaded('mbstring');// @phpstan-ignore-next-line- $data = DATA_PATH && is_writable(DATA_PATH);+ $data = DATA_PATH && touch(DATA_PATH . '/index.html'); // is_writable() is not reliable for a folder on NFS// @phpstan-ignore-next-line- $cache = CACHE_PATH && is_writable(CACHE_PATH);+ $cache = CACHE_PATH && touch(CACHE_PATH . '/index.html');// @phpstan-ignore-next-line$tmp = TMP_PATH && is_writable(TMP_PATH);// @phpstan-ignore-next-line- $users = USERS_PATH && is_writable(USERS_PATH);- $favicons = is_writable(join_path(DATA_PATH, 'favicons'));+ $users = USERS_PATH && touch(USERS_PATH . '/index.html');+ $favicons = touch(DATA_PATH . '/favicons/index.html');return array('php' => $php ? 'ok' : 'ko',diff --git a/lib/lib_rss.php b/lib/lib_rss.phpindex 592ad8149..d0e819d98 100644--- a/lib/lib_rss.php+++ b/lib/lib_rss.php@@ -696,13 +696,13 @@ function check_install_php() {function check_install_files() {return array(// @phpstan-ignore-next-line- 'data' => DATA_PATH && is_writable(DATA_PATH),+ 'data' => DATA_PATH && touch(DATA_PATH . '/index.html'), // is_writable() is not reliable for a folder on NFS// @phpstan-ignore-next-line- 'cache' => CACHE_PATH && is_writable(CACHE_PATH),+ 'cache' => CACHE_PATH && touch(CACHE_PATH . '/index.html'),// @phpstan-ignore-next-line- 'users' => USERS_PATH && is_writable(USERS_PATH),- 'favicons' => is_writable(DATA_PATH . '/favicons'),- 'tokens' => is_writable(DATA_PATH . '/tokens'),+ 'users' => USERS_PATH && touch(USERS_PATH . '/index.html'),+ 'favicons' => touch(DATA_PATH . '/favicons/index.html'),+ 'tokens' => touch(DATA_PATH . '/tokens/index.html'),);}