diff --git a/caches/FileCache.php b/caches/FileCache.php index 3447aa76..a4f48962 100644 --- a/caches/FileCache.php +++ b/caches/FileCache.php @@ -41,9 +41,9 @@ class FileCache implements CacheInterface public function saveData($data): void { - $writeStream = file_put_contents($this->getCacheFile(), serialize($data)); - if ($writeStream === false) { - throw new \Exception('The cache path is not writeable. You probably want: chown www-data:www-data cache'); + $bytes = file_put_contents($this->getCacheFile(), serialize($data), LOCK_EX); + if ($bytes === false) { + throw new \Exception(sprintf('Failed to write to: %s', $this->getCacheFile())); } } diff --git a/lib/Logger.php b/lib/Logger.php index 22553dce..b97de978 100644 --- a/lib/Logger.php +++ b/lib/Logger.php @@ -77,6 +77,6 @@ final class Logger // Log to file // todo: extract to log handler - //file_put_contents('/tmp/rss-bridge.log', $text, FILE_APPEND); + // file_put_contents('/tmp/rss-bridge.log', $text, FILE_APPEND | LOCK_EX); } }