Make flock writing easier

This commit is contained in:
Philipp 2023-01-04 08:16:40 +01:00
parent c057954896
commit aabe39220d
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432

View File

@ -214,10 +214,9 @@ class ConfigFileManager
throw new ConfigFileException('config source cannot get encoded'); throw new ConfigFileException('config source cannot get encoded');
} }
$configStream = fopen($this->configDir . '/' . self::CONFIG_DATA_FILE, 'w+'); $configStream = fopen($this->configDir . '/' . self::CONFIG_DATA_FILE, 'w');
if (flock($configStream, LOCK_EX)) { if (flock($configStream, LOCK_EX)) {
ftruncate($configStream, 0);
fwrite($configStream, $encodedData); fwrite($configStream, $encodedData);
fflush($configStream); fflush($configStream);
flock($configStream, LOCK_UN); flock($configStream, LOCK_UN);