Merge pull request #1981 from nextcloud/enh/noid/increase-free-disk-check

check size of config and only write back if space is sufficient
This commit is contained in:
Simon L 2023-02-16 17:24:35 +01:00 committed by GitHub
commit 775889edc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -453,10 +453,12 @@ class ConfigurationManager
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not exist! Something was set up falsely!");
}
$df = disk_free_space(DataConst::GetDataDirectory());
if ($df !== false && (int)$df < 10240) {
$content = json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$size = strlen($content) + 10240;
if ($df !== false && (int)$df < $size) {
throw new InvalidSettingConfigurationException(DataConst::GetDataDirectory() . " does not have enough space for writing the config file! Not writing it back!");
}
file_put_contents(DataConst::GetConfigFile(), json_encode($config, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT));
file_put_contents(DataConst::GetConfigFile(), $content);
}
private function GetEnvironmentalVariableOrConfig(string $envVariableName, string $configName, string $defaultValue) : string {