Allow declaration of background jobs in info.xml
This commit is contained in:
parent
adf7e7295e
commit
71fa0a75bf
4 changed files with 20 additions and 5 deletions
|
@ -89,6 +89,9 @@ class InfoParser {
|
||||||
if (!array_key_exists('uninstall', $array['repair-steps'])) {
|
if (!array_key_exists('uninstall', $array['repair-steps'])) {
|
||||||
$array['repair-steps']['uninstall'] = [];
|
$array['repair-steps']['uninstall'] = [];
|
||||||
}
|
}
|
||||||
|
if (!array_key_exists('background-jobs', $array)) {
|
||||||
|
$array['background-jobs'] = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
|
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
|
||||||
foreach ($array['documentation'] as $key => $url) {
|
foreach ($array['documentation'] as $key => $url) {
|
||||||
|
@ -128,6 +131,9 @@ class InfoParser {
|
||||||
if (isset($array['repair-steps']['uninstall']['step']) && is_array($array['repair-steps']['uninstall']['step'])) {
|
if (isset($array['repair-steps']['uninstall']['step']) && is_array($array['repair-steps']['uninstall']['step'])) {
|
||||||
$array['repair-steps']['uninstall'] = $array['repair-steps']['uninstall']['step'];
|
$array['repair-steps']['uninstall'] = $array['repair-steps']['uninstall']['step'];
|
||||||
}
|
}
|
||||||
|
if (isset($array['background-jobs']['job']) && is_array($array['background-jobs']['job'])) {
|
||||||
|
$array['background-jobs'] = $array['background-jobs']['job'];
|
||||||
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +153,7 @@ class InfoParser {
|
||||||
if (!isset($array[$element])) {
|
if (!isset($array[$element])) {
|
||||||
$array[$element] = "";
|
$array[$element] = "";
|
||||||
}
|
}
|
||||||
/**
|
/** @var \SimpleXMLElement $node */
|
||||||
* @var \SimpleXMLElement $node
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Has attributes
|
// Has attributes
|
||||||
if ($attributes = $node->attributes()) {
|
if ($attributes = $node->attributes()) {
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
@ -133,6 +133,8 @@ class Installer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\OC_App::setupBackgroundJobs($info['background-jobs']);
|
||||||
|
|
||||||
//run appinfo/install.php
|
//run appinfo/install.php
|
||||||
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
|
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
|
||||||
self::includeAppScript($basedir . '/appinfo/install.php');
|
self::includeAppScript($basedir . '/appinfo/install.php');
|
||||||
|
@ -569,6 +571,7 @@ class Installer {
|
||||||
if (is_null($info)) {
|
if (is_null($info)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
\OC_App::setupBackgroundJobs($info['background-jobs']);
|
||||||
|
|
||||||
OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
|
OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
|
||||||
|
|
||||||
|
|
|
@ -1190,6 +1190,7 @@ class OC_App {
|
||||||
self::loadApp($appId, false);
|
self::loadApp($appId, false);
|
||||||
include $appPath . '/appinfo/update.php';
|
include $appPath . '/appinfo/update.php';
|
||||||
}
|
}
|
||||||
|
self::setupBackgroundJobs($appData['background-jobs']);
|
||||||
|
|
||||||
//set remote/public handlers
|
//set remote/public handlers
|
||||||
if (array_key_exists('ocsid', $appData)) {
|
if (array_key_exists('ocsid', $appData)) {
|
||||||
|
@ -1240,6 +1241,13 @@ class OC_App {
|
||||||
$r->run();
|
$r->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function setupBackgroundJobs(array $jobs) {
|
||||||
|
$queue = \OC::$server->getJobList();
|
||||||
|
foreach ($jobs as $job) {
|
||||||
|
$queue->add($job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $appId
|
* @param string $appId
|
||||||
* @param string[] $steps
|
* @param string[] $steps
|
||||||
|
|
|
@ -74,5 +74,6 @@
|
||||||
"post-migration": [],
|
"post-migration": [],
|
||||||
"live-migration": [],
|
"live-migration": [],
|
||||||
"uninstall": []
|
"uninstall": []
|
||||||
}
|
},
|
||||||
|
"background-jobs": []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue