Make borg_restore_password an attribute

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-19 12:16:30 +01:00
parent 6df0333f71
commit f030abcafd
3 changed files with 11 additions and 16 deletions

View file

@ -114,7 +114,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
'is_onlyoffice_enabled' => $configurationManager->isOnlyofficeEnabled,
'is_collabora_enabled' => $configurationManager->isCollaboraEnabled,
'is_talk_enabled' => $configurationManager->isTalkEnabled,
'borg_restore_password' => $configurationManager->GetBorgRestorePassword(),
'borg_restore_password' => $configurationManager->borg_restore_password,
'daily_backup_time' => $configurationManager->GetDailyBackupTime(),
'is_daily_backup_running' => $configurationManager->isDailyBackupRunning(),
'timezone' => $configurationManager->GetTimezone(),

View file

@ -119,6 +119,11 @@ class ConfigurationManager
set { $this->set('borg_remote_repo', $value); }
}
public string $borg_restore_password {
get => $this->get('borg_restore_password', '');
set { $this->set('borg_restore_password', $value); }
}
public function GetConfig() : array
{
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
@ -364,13 +369,13 @@ class ConfigurationManager
}
$config = $this->GetConfig();
// Reset the borg restore password when setting the domain
$config['borg_restore_password'] = '';
$this->WriteConfig($config);
$this->setMultiple(function ($confManager) use ($domain) {
// Write domain
// Don't set the domain via the attribute, or we create a loop.
$confManager->set('domain', $domain);
// Reset the borg restore password when setting the domain
$confManager->borg_restore_password = '';
});
}
@ -465,12 +470,11 @@ class ConfigurationManager
}
$config = $this->GetConfig();
$config['borg_restore_password'] = $password;
$this->WriteConfig($config);
$this->setMultiple(function ($confManager) use ($location, $repo) {
$this->setMultiple(function ($confManager) use ($location, $repo, $password) {
$confManager->borg_backup_host_location = $location;
$confManager->borg_remote_repo = $repo;
$confManager->borg_restore_password = $password;
$confManager->instance_restore_attempt = true;
});
}
@ -578,15 +582,6 @@ class ConfigurationManager
return trim((string)file_get_contents(DataConst::GetBackupPublicKey()));
}
public function GetBorgRestorePassword() : string {
$config = $this->GetConfig();
if(!isset($config['borg_restore_password'])) {
$config['borg_restore_password'] = '';
}
return $config['borg_restore_password'];
}
public function GetNextcloudMount() : string {
$envVariableName = 'NEXTCLOUD_MOUNT';
$configName = 'nextcloud_mount';

View file

@ -570,7 +570,7 @@ readonly class DockerActionManager {
'TALK_PORT' => $this->configurationManager->GetTalkPort(),
'TURN_DOMAIN' => $this->configurationManager->GetTurnDomain(),
'NEXTCLOUD_MOUNT' => $this->configurationManager->GetNextcloudMount(),
'BACKUP_RESTORE_PASSWORD' => $this->configurationManager->GetBorgRestorePassword(),
'BACKUP_RESTORE_PASSWORD' => $this->configurationManager->borg_restore_password,
'CLAMAV_ENABLED' => $this->configurationManager->isClamavEnabled ? 'yes' : '',
'TALK_RECORDING_ENABLED' => $this->configurationManager->isTalkRecordingEnabled ? 'yes' : '',
'ONLYOFFICE_ENABLED' => $this->configurationManager->isOnlyofficeEnabled ? 'yes' : '',