diff --git a/php/public/index.php b/php/public/index.php index f3e8f940..eb214eff 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -93,7 +93,7 @@ $app->get('/containers', function (Request $request, Response $response, array $ return $view->render($response, 'containers.twig', [ 'domain' => $configurationManager->domain, 'apache_port' => $configurationManager->GetApachePort(), - 'borg_backup_host_location' => $configurationManager->GetBorgBackupHostLocation(), + 'borg_backup_host_location' => $configurationManager->borg_backup_host_location, 'borg_remote_repo' => $configurationManager->GetBorgRemoteRepo(), 'borg_public_key' => $configurationManager->GetBorgPublicKey(), 'nextcloud_password' => $configurationManager->GetAndGenerateSecret('NEXTCLOUD_PASSWORD'), diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index 4ac53258..e8244ddc 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -113,7 +113,7 @@ readonly class ContainerDefinitionFetcher { if (isset($entry['volumes'])) { foreach ($entry['volumes'] as $value) { if($value['source'] === '%BORGBACKUP_HOST_LOCATION%') { - $value['source'] = $this->configurationManager->GetBorgBackupHostLocation(); + $value['source'] = $this->configurationManager->borg_backup_host_location; if($value['source'] === '') { continue; } diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index d276ebb7..1c93f51b 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -109,6 +109,11 @@ class ConfigurationManager set { $this->SetDomain($value); } } + public string $borg_backup_host_location { + get => $this->get('borg_backup_host_location', ''); + set { $this->set('borg_backup_host_location', $value); } + } + public function GetConfig() : array { if ($this->config === [] && file_exists(DataConst::GetConfigFile())) @@ -379,9 +384,11 @@ class ConfigurationManager $this->ValidateBorgLocationVars($location, $repo); $config = $this->GetConfig(); - $config['borg_backup_host_location'] = $location; $config['borg_remote_repo'] = $repo; $this->WriteConfig($config); + $this->setMultiple(function ($confManager) use ($location) { + $confManager->borg_backup_host_location = $location; + }); } private function ValidateBorgLocationVars(string $location, string $repo) : void { @@ -428,9 +435,11 @@ class ConfigurationManager public function DeleteBorgBackupLocationItems() : void { // Delete the variables $config = $this->GetConfig(); - $config['borg_backup_host_location'] = ''; $config['borg_remote_repo'] = ''; $this->WriteConfig($config); + $this->setMultiple(function ($confManager) { + $confManager->borg_backup_host_location = ''; + }); // Also delete the borg config file to be able to start over if (file_exists(DataConst::GetBackupKeyFile())) { @@ -451,12 +460,12 @@ class ConfigurationManager } $config = $this->GetConfig(); - $config['borg_backup_host_location'] = $location; $config['borg_remote_repo'] = $repo; $config['borg_restore_password'] = $password; $this->WriteConfig($config); - $this->setMultiple(function ($confManager) { + $this->setMultiple(function ($confManager) use ($location) { + $confManager->borg_backup_host_location = $location; $confManager->instance_restore_attempt = true; }); } @@ -556,15 +565,6 @@ class ConfigurationManager return $envVariableOutput; } - public function GetBorgBackupHostLocation() : string { - $config = $this->GetConfig(); - if(!isset($config['borg_backup_host_location'])) { - $config['borg_backup_host_location'] = ''; - } - - return $config['borg_backup_host_location']; - } - public function GetBorgRemoteRepo() : string { $config = $this->GetConfig(); if(!isset($config['borg_remote_repo'])) { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 73f4bd9d..a3ea0c9b 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -589,7 +589,7 @@ readonly class DockerActionManager { 'FULLTEXTSEARCH_JAVA_OPTIONS' => $this->configurationManager->GetFulltextsearchJavaOptions(), 'NEXTCLOUD_TRUSTED_CACERTS_DIR' => $this->configurationManager->GetTrustedCacertsDir(), 'ADDITIONAL_DIRECTORIES_BACKUP' => $this->configurationManager->GetAdditionalBackupDirectoriesString() !== '' ? 'yes' : '', - 'BORGBACKUP_HOST_LOCATION' => $this->configurationManager->GetBorgBackupHostLocation(), + 'BORGBACKUP_HOST_LOCATION' => $this->configurationManager->borg_backup_host_location, 'APACHE_MAX_SIZE' => (string)($this->configurationManager->GetApacheMaxSize()), 'COLLABORA_SECCOMP_POLICY' => $this->configurationManager->GetCollaboraSeccompPolicy(), 'NEXTCLOUD_STARTUP_APPS' => $this->configurationManager->GetNextcloudStartupApps(),