mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 15:19:55 +03:00
fix(file cache): acquire lock before writing (#3509)
This commit is contained in:
parent
8b996e3056
commit
91976f7d56
2 changed files with 4 additions and 4 deletions
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue