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'])) {
|
||||
$array['repair-steps']['uninstall'] = [];
|
||||
}
|
||||
if (!array_key_exists('background-jobs', $array)) {
|
||||
$array['background-jobs'] = [];
|
||||
}
|
||||
|
||||
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
|
||||
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'])) {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -147,10 +153,7 @@ class InfoParser {
|
|||
if (!isset($array[$element])) {
|
||||
$array[$element] = "";
|
||||
}
|
||||
/**
|
||||
* @var \SimpleXMLElement $node
|
||||
*/
|
||||
|
||||
/** @var \SimpleXMLElement $node */
|
||||
// Has attributes
|
||||
if ($attributes = $node->attributes()) {
|
||||
$data = [
|
||||
|
|
|
@ -133,6 +133,8 @@ class Installer {
|
|||
}
|
||||
}
|
||||
|
||||
\OC_App::setupBackgroundJobs($info['background-jobs']);
|
||||
|
||||
//run appinfo/install.php
|
||||
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
|
||||
self::includeAppScript($basedir . '/appinfo/install.php');
|
||||
|
@ -569,6 +571,7 @@ class Installer {
|
|||
if (is_null($info)) {
|
||||
return false;
|
||||
}
|
||||
\OC_App::setupBackgroundJobs($info['background-jobs']);
|
||||
|
||||
OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
|
||||
|
||||
|
|
|
@ -1190,6 +1190,7 @@ class OC_App {
|
|||
self::loadApp($appId, false);
|
||||
include $appPath . '/appinfo/update.php';
|
||||
}
|
||||
self::setupBackgroundJobs($appData['background-jobs']);
|
||||
|
||||
//set remote/public handlers
|
||||
if (array_key_exists('ocsid', $appData)) {
|
||||
|
@ -1240,6 +1241,13 @@ class OC_App {
|
|||
$r->run();
|
||||
}
|
||||
|
||||
public static function setupBackgroundJobs(array $jobs) {
|
||||
$queue = \OC::$server->getJobList();
|
||||
foreach ($jobs as $job) {
|
||||
$queue->add($job);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appId
|
||||
* @param string[] $steps
|
||||
|
|
|
@ -74,5 +74,6 @@
|
|||
"post-migration": [],
|
||||
"live-migration": [],
|
||||
"uninstall": []
|
||||
}
|
||||
},
|
||||
"background-jobs": []
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue