Allow declaration of background jobs in info.xml

This commit is contained in:
Thomas Müller 2016-05-02 15:26:12 +02:00
parent adf7e7295e
commit 71fa0a75bf
No known key found for this signature in database
GPG key ID: A943788A3BBEC44C
4 changed files with 20 additions and 5 deletions

View file

@ -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 = [

View file

@ -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']);

View file

@ -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

View file

@ -74,5 +74,6 @@
"post-migration": [],
"live-migration": [],
"uninstall": []
}
},
"background-jobs": []
}