Merge pull request #326 from nextcloud/enh/271/allow-to-change-datadir

allow to change the location of Nextclouds datadir
This commit is contained in:
Simon L 2022-03-09 12:41:58 +01:00 committed by GitHub
commit d170feb1e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 2 deletions

View file

@ -337,4 +337,27 @@ class ConfigurationManager
return $mount;
}
}
public function GetNextcloudDatadirMount() : string {
$mount = getenv('NEXTCLOUD_DATADIR');
if ($mount === false) {
$config = $this->GetConfig();
if (!isset($config['nextcloud_datadir']) || $config['nextcloud_datadir'] === '') {
$config['nextcloud_datadir'] = 'nextcloud_aio_nextcloud_data';
}
return $config['nextcloud_datadir'];
} else {
if(file_exists(DataConst::GetConfigFile())) {
$config = $this->GetConfig();
if (!isset($config['nextcloud_datadir'])) {
$config['nextcloud_datadir'] = '';
}
if ($mount !== $config['nextcloud_datadir']) {
$config['nextcloud_datadir'] = $mount;
$this->WriteConfig($config);
}
}
return $mount;
}
}
}