speed up plugin updating a bit, fix some phpstan warnings

This commit is contained in:
Andrew Dolgov 2021-02-28 21:50:05 +03:00
parent bf02afed45
commit b05d4e3d9f
4 changed files with 18 additions and 7 deletions

View File

@ -363,6 +363,7 @@ class API extends Handler {
} }
$this->_wrap(self::STATUS_OK, $articles); $this->_wrap(self::STATUS_OK, $articles);
// @phpstan-ignore-next-line
} else { } else {
$this->_wrap(self::STATUS_ERR, array("error" => self::E_INCORRECT_USAGE)); $this->_wrap(self::STATUS_ERR, array("error" => self::E_INCORRECT_USAGE));
} }

View File

@ -1185,15 +1185,18 @@ class Pref_Prefs extends Handler_Protected {
function updateLocalPlugins() { function updateLocalPlugins() {
if ($_SESSION["access_level"] >= 10) { if ($_SESSION["access_level"] >= 10) {
$plugin_name = $_REQUEST["name"] ?? ""; $plugins = explode(",", $_REQUEST["plugins"] ?? "");
# we're in classes/pref/ # we're in classes/pref/
$root_dir = dirname(dirname(__DIR__)); $root_dir = dirname(dirname(__DIR__));
$rv = []; $rv = [];
if (!empty($plugin_name)) { if (count($plugins) > 0) {
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_update_plugin($root_dir, $plugin_name)]); foreach ($plugins as $plugin_name) {
array_push($rv, ["plugin" => $plugin_name, "rv" => $this->_update_plugin($root_dir, $plugin_name)]);
}
// @phpstan-ignore-next-line
} else { } else {
$plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir"); $plugin_dirs = array_filter(glob("$root_dir/plugins.local/*"), "is_dir");

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global __, dijit, dojo, Tables, xhrPost, Notify, xhr, App, fox */ /* global __, dijit, dojo, Tables, Notify, xhr, App, fox */
const Helpers = { const Helpers = {
AppPasswords: { AppPasswords: {
@ -327,6 +327,7 @@ const Helpers = {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
title: __("Plugin Updater"), title: __("Plugin Updater"),
need_refresh: false, need_refresh: false,
plugins_to_update: [],
onHide: function() { onHide: function() {
if (this.need_refresh) { if (this.need_refresh) {
Helpers.Prefs.refresh(); Helpers.Prefs.refresh();
@ -335,10 +336,12 @@ const Helpers = {
performUpdate: function() { performUpdate: function() {
const container = dialog.domNode.querySelector(".update-results"); const container = dialog.domNode.querySelector(".update-results");
console.log('updating', dialog.plugins_to_update);
container.innerHTML = `<li class='text-center'>${__("Updating, please wait...")}</li>`; container.innerHTML = `<li class='text-center'>${__("Updating, please wait...")}</li>`;
let enable_update_btn = false; let enable_update_btn = false;
xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", name: name}, (reply) => { xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", plugins: dialog.plugins_to_update.join(",")}, (reply) => {
if (!reply) { if (!reply) {
container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`; container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`;
@ -392,9 +395,13 @@ const Helpers = {
} else { } else {
container.innerHTML = ""; container.innerHTML = "";
dialog.plugins_to_update = [];
reply.forEach((p) => { reply.forEach((p) => {
if (p.rv.s == 0) if (p.rv.s == 0) {
enable_update_btn = true; enable_update_btn = true;
dialog.plugins_to_update.push(p.plugin);
}
container.innerHTML += container.innerHTML +=
` `

View File

@ -253,7 +253,7 @@
RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : Config::get(Config::DAEMON_FEED_LIMIT), $options); RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : Config::get(Config::DAEMON_FEED_LIMIT), $options);
if (!isset($options["pidlock"]) || $options["task"] == 0) if (!isset($options["pidlock"]) || $options["task"] == "0")
RSSUtils::housekeeping_common(); RSSUtils::housekeeping_common();
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, $options); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, $options);