X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=application%2Fhelper%2FApplicationUtils.php;h=a6c03aaeae899daebb46bb37884dc3422694b6d0;hb=8a6b7e96b7176e03238bbb1bcaa4c8b0c25e6358;hp=212dd8e2dc7578aa6da6a3f8d403fff319ae3f42;hpb=e4b8330e459b598328bf250208386c06ec257b08;p=github%2Fshaarli%2FShaarli.git diff --git a/application/helper/ApplicationUtils.php b/application/helper/ApplicationUtils.php index 212dd8e2..a6c03aae 100644 --- a/application/helper/ApplicationUtils.php +++ b/application/helper/ApplicationUtils.php @@ -3,6 +3,8 @@ namespace Shaarli\Helper; use Exception; +use malkusch\lock\exception\LockAcquireException; +use malkusch\lock\mutex\FlockMutex; use Shaarli\Config\ConfigManager; /** @@ -252,6 +254,20 @@ class ApplicationUtils return $errors; } + public static function checkDatastoreMutex(): array + { + $mutex = new FlockMutex(fopen(SHAARLI_MUTEX_FILE, 'r'), 2); + try { + $mutex->synchronized(function () { + return true; + }); + } catch (LockAcquireException $e) { + $errors[] = t('Lock can not be acquired on the datastore. You might encounter concurrent access issues.'); + } + + return $errors ?? []; + } + /** * Returns a salted hash representing the current Shaarli version. *