mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-02-17 03:00:21 +00:00
Don't reload config if saving from a getter
Without this there's race conditions Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
parent
e31bc55230
commit
0332929034
1 changed files with 6 additions and 4 deletions
|
|
@ -59,7 +59,7 @@ class ConfigurationManager
|
||||||
$this->GetConfig();
|
$this->GetConfig();
|
||||||
if(!isset($this->config['secrets'][$secretId])) {
|
if(!isset($this->config['secrets'][$secretId])) {
|
||||||
$this->config['secrets'][$secretId] = bin2hex(random_bytes(24));
|
$this->config['secrets'][$secretId] = bin2hex(random_bytes(24));
|
||||||
$this->save();
|
$this->save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($secretId === 'BORGBACKUP_PASSWORD' && !file_exists(DataConst::GetBackupSecretFile())) {
|
if ($secretId === 'BORGBACKUP_PASSWORD' && !file_exists(DataConst::GetBackupSecretFile())) {
|
||||||
|
|
@ -604,7 +604,7 @@ class ConfigurationManager
|
||||||
/**
|
/**
|
||||||
* @throws InvalidSettingConfigurationException
|
* @throws InvalidSettingConfigurationException
|
||||||
*/
|
*/
|
||||||
public function save() : void {
|
public function save(bool $reload = true) : void {
|
||||||
if(!is_dir(DataConst::GetDataDirectory())) {
|
if(!is_dir(DataConst::GetDataDirectory())) {
|
||||||
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!");
|
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!");
|
||||||
}
|
}
|
||||||
|
|
@ -617,7 +617,9 @@ class ConfigurationManager
|
||||||
file_put_contents(DataConst::GetConfigFile(), $content);
|
file_put_contents(DataConst::GetConfigFile(), $content);
|
||||||
// Force reloading the config after it was written. It's not clear to me if keeping the config loaded
|
// Force reloading the config after it was written. It's not clear to me if keeping the config loaded
|
||||||
// might cause race conditions, e.g. in case multiple processes write to the file, so better safe than sorry.
|
// might cause race conditions, e.g. in case multiple processes write to the file, so better safe than sorry.
|
||||||
$this->config = [];
|
if ($reload) {
|
||||||
|
$this->config = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function GetEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {
|
private function GetEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {
|
||||||
|
|
@ -636,7 +638,7 @@ class ConfigurationManager
|
||||||
}
|
}
|
||||||
if ($envVariableOutput !== $config[$configName]) {
|
if ($envVariableOutput !== $config[$configName]) {
|
||||||
$this->config[$configName] = $envVariableOutput;
|
$this->config[$configName] = $envVariableOutput;
|
||||||
$this->save();
|
$this->save(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $envVariableOutput;
|
return $envVariableOutput;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue