Commit 73cd44e7 authored by Franco Fichtner's avatar Franco Fichtner

firmware: flip remote array to emulate local array layout

parent f11b72dc
...@@ -130,19 +130,18 @@ class FirmwareController extends ApiControllerBase ...@@ -130,19 +130,18 @@ class FirmwareController extends ApiControllerBase
{ {
$this->sessionClose(); // long running action, close session $this->sessionClose(); // long running action, close session
$response = array('local' => array(), 'remote' => array());
$backend = new Backend(); $backend = new Backend();
$remote = $backend->configdRun('firmware remote'); $remote = $backend->configdRun('firmware remote');
$local = $backend->configdRun('firmware local'); $local = $backend->configdRun('firmware local');
/* /*
* pkg(8) returns malformed json by simply outputting each * pkg(8) returns malformed json by simply outputting each
* indivudual package json block... fix it up for now. * indivudual package json block... fix it up for now.
*/ */
$local = str_replace("\n}\n", "\n},\n", trim($local)); $local = str_replace("\n}\n", "\n},\n", trim($local));
$local = json_decode('[' . $local . ']', true); $local = json_decode('[' . $local . ']', true);
/* Remote packages are only a flat list */
$remote = explode("\n", trim($remote));
$response = array('local' => array(), 'remote' => $remote);
if ($local != null) { if ($local != null) {
$keep = array('name', 'version', 'comment', 'www', 'flatsize', 'licenses', 'desc', 'categories'); $keep = array('name', 'version', 'comment', 'www', 'flatsize', 'licenses', 'desc', 'categories');
foreach ($local as $infos) { foreach ($local as $infos) {
...@@ -156,6 +155,13 @@ class FirmwareController extends ApiControllerBase ...@@ -156,6 +155,13 @@ class FirmwareController extends ApiControllerBase
} }
} }
/* Remote packages are only a flat list */
$remote = explode("\n", trim($remote));
foreach ($remote as $name) {
/* keep layout compatible with the above */
$response['remote'][] = array('name' => $name);
}
return $response; return $response;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment