initialize remote data in one go

Previously each extension was fetched separately from the API, this
fetches all installed ones in one go, speeding up the first open on cold
cache significantly.
This commit is contained in:
Andreas Gohr
2024-12-17 12:07:22 +01:00
parent dc19220032
commit 01b2a2823d
3 changed files with 19 additions and 3 deletions

View File

@ -64,6 +64,12 @@ class GuiAdmin extends Gui
$html .= '</div>';
$plugins = (new Local())->getPlugins();
try {
// initialize remote data in one go
Repository::getInstance()->initExtensions(array_keys($plugins));
} catch (Exception $e) {
msg($e->getMessage(), -1); // this should not happen
}
$html .= '<div id="extension__list">';
$html .= '<form action="' . $this->tabURL('plugins') . '" method="post">';
@ -91,6 +97,12 @@ class GuiAdmin extends Gui
$html .= '</div>';
$templates = (new Local())->getTemplates();
try {
// initialize remote data in one go
Repository::getInstance()->initExtensions(array_keys($templates));
} catch (Exception $e) {
msg($e->getMessage(), -1); // this should not happen
}
$html .= '<div id="extension__list">';
$html .= '<form action="' . $this->tabURL('templates') . '" method="post">';

View File

@ -135,7 +135,7 @@ class Repository
// first get all that are cached
foreach ($ids as $id) {
$data = $this->retrieveCache($id);
if ($data === null) {
if ($data === null || $data === []) {
$toload[] = $id;
} else {
$result[$id] = Extension::createFromRemoteData($data);
@ -147,7 +147,7 @@ class Repository
$this->fetchExtensions($toload);
foreach ($toload as $id) {
$data = $this->retrieveCache($id);
if ($data === null) {
if ($data === null || $data === []) {
$result[$id] = null;
} else {
$result[$id] = Extension::createFromRemoteData($data);

View File

@ -258,7 +258,11 @@ class cli_plugin_extension extends CLIPlugin
*/
protected function cmdList($showdetails, $filter)
{
$this->listExtensions((new Local())->getExtensions(), $showdetails, $filter);
$extensions = (new Local())->getExtensions();
// initialize remote data in one go
Repository::getInstance()->initExtensions(array_keys($extensions));
$this->listExtensions($extensions, $showdetails, $filter);
return 0;
}