mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-06-10 08:37:02 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2be6039bfd |
@@ -12,6 +12,8 @@ class ConfigurationManager
|
|||||||
|
|
||||||
private array $config = [];
|
private array $config = [];
|
||||||
|
|
||||||
|
private int $configMtime = 0;
|
||||||
|
|
||||||
private bool $noWrite = false;
|
private bool $noWrite = false;
|
||||||
|
|
||||||
private string $dailyBackupFileCache = '';
|
private string $dailyBackupFileCache = '';
|
||||||
@@ -299,13 +301,21 @@ class ConfigurationManager
|
|||||||
|
|
||||||
private function getConfig() : array
|
private function getConfig() : array
|
||||||
{
|
{
|
||||||
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
|
$configFile = DataConst::GetConfigFile();
|
||||||
{
|
if (file_exists($configFile)) {
|
||||||
$configContent = (string)file_get_contents(DataConst::GetConfigFile());
|
$mtime = filemtime($configFile);
|
||||||
if ($configContent === '') {
|
if ($mtime !== false && $mtime !== $this->configMtime) {
|
||||||
throw new \RuntimeException("The config file " . DataConst::GetConfigFile() . " is empty. It may have been truncated due to low disk space. Please restore it from a backup.");
|
$configContent = (string)file_get_contents($configFile);
|
||||||
|
$this->config = json_decode($configContent, true, 512, JSON_THROW_ON_ERROR);
|
||||||
|
$configContent = (string)file_get_contents(DataConst::GetConfigFile());
|
||||||
|
if ($configContent === '') {
|
||||||
|
throw new \RuntimeException("The config file " . DataConst::GetConfigFile() . " is empty. It may have been truncated due to low disk space. Please restore it from a backup.");
|
||||||
|
}
|
||||||
|
$this->configMtime = $mtime;
|
||||||
}
|
}
|
||||||
$this->config = json_decode($configContent, true, 512, JSON_THROW_ON_ERROR);
|
} else {
|
||||||
|
$this->config = [];
|
||||||
|
$this->configMtime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->config;
|
return $this->config;
|
||||||
@@ -720,7 +730,14 @@ class ConfigurationManager
|
|||||||
unlink($tempFile);
|
unlink($tempFile);
|
||||||
throw new InvalidSettingConfigurationException("Failed to rename " . $tempFile . " to " . DataConst::GetConfigFile());
|
throw new InvalidSettingConfigurationException("Failed to rename " . $tempFile . " to " . DataConst::GetConfigFile());
|
||||||
}
|
}
|
||||||
$this->config = [];
|
clearstatcache(true, DataConst::GetConfigFile());
|
||||||
|
$mtime = filemtime(DataConst::GetConfigFile());
|
||||||
|
if ($mtime !== false) {
|
||||||
|
$this->configMtime = $mtime;
|
||||||
|
} else {
|
||||||
|
$this->config = [];
|
||||||
|
$this->configMtime = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {
|
private function getEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {
|
||||||
|
|||||||
Reference in New Issue
Block a user