Backgroundjobs: Add reset counter in worker

This commit is contained in:
Jakob Sack 2012-08-09 22:30:11 +02:00
parent 66511469e0
commit f46fdfd814
1 changed files with 11 additions and 2 deletions

View File

@ -36,16 +36,25 @@ class OC_BackgroundJob_Worker{
*/
public static function doAllSteps(){
// Do our regular work
$lasttask = OC_Appconfig::getValue( 'core', 'backgroundjobs_task', '' );
$regular_tasks = OC_BackgroundJob_RegularTask::all();
ksort( $regular_tasks );
foreach( $regular_tasks as $key => $value ){
call_user_func( $value );
if( strcmp( $key, $lasttask ) > 0 ){
// Set "restart here" config value
OC_Appconfig::setValue( 'core', 'backgroundjobs_task', $key );
call_user_func( $value );
}
}
// Reset "start here" config value
OC_Appconfig::setValue( 'core', 'backgroundjobs_task', '' );
// Do our queued tasks
$queued_tasks = OC_BackgroundJob_QueuedTask::all();
foreach( $queued_tasks as $task ){
call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] );
OC_BackgroundJob_QueuedTask::delete( $task['id'] );
call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] );
}
return true;