Skip to content

Commit

Permalink
System: Configuration: History - when omitting the backup filename (c…
Browse files Browse the repository at this point in the history
…ontaining a timestamp), offer the latest one found based on filename. Since backup filenames contain a timestamp, `array_reverse(glob())` should provide the latest first.

PR: #6996

Endpoint without explicit filename for this host :  https://xxx.xxx.xxx.xxx/api/core/backup/download/this

(cherry picked from commit 0227baf)
(cherry picked from commit 7ee772a)
  • Loading branch information
AdSchellevis authored and fichtner committed Nov 9, 2023
1 parent 3e380ff commit 39b5317
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -183,14 +183,14 @@ public function revertBackupAction($backup)
}

/**
* download specified backup
* download specified backup, when left empty the latest is offered
*/
public function downloadAction($host, $backup)
public function downloadAction($host, $backup = null)
{
$providers = $this->providers();
if (!empty($providers[$host])) {
foreach (glob($providers[$host]['dirname'] . "/config-*.xml") as $filename) {
if ($backup == basename($filename)) {
foreach (array_reverse(glob($providers[$host]['dirname'] . "/config-*.xml")) as $filename) {
if (empty($backup) || $backup == basename($filename)) {
$payload = @simplexml_load_file($filename);
$hostname = '';
if ($payload !== false && isset($payload->system) && isset($payload->system->hostname)) {
Expand Down

0 comments on commit 39b5317

Please sign in to comment.