diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-27 16:45:13 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-04-28 23:41:38 -0300 |
commit | 7340d6a56c1b4becb75da41b33239357efc530a5 (patch) | |
tree | 7046ec7678797050029afc7b7bd92831bacf9c46 /apps/lookup_server_connector | |
parent | 4ec05ef0507d840f18bebc7750b05e31a67bc21b (diff) | |
download | nextcloud-server-7340d6a56c1b4becb75da41b33239357efc530a5.tar.gz nextcloud-server-7340d6a56c1b4becb75da41b33239357efc530a5.zip |
don't add multiple retry jobs
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/lookup_server_connector')
-rw-r--r-- | apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php index f33323b2d4f..faeef05da17 100644 --- a/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php +++ b/apps/lookup_server_connector/lib/BackgroundJobs/RetryJob.php @@ -26,6 +26,7 @@ namespace OCA\LookupServerConnector\BackgroundJobs; use OC\BackgroundJob\Job; use OCP\BackgroundJob\IJobList; use OCP\Http\Client\IClientService; +use OCP\ILogger; class RetryJob extends Job { /** @var IClientService */ @@ -36,21 +37,28 @@ class RetryJob extends Job { private $lookupServer = 'https://lookup.nextcloud.com/users'; /** - * @param IClientService|null $clientService - * @param IJobList|null $jobList + * @param IClientService $clientService + * @param IJobList $jobList */ - public function __construct(IClientService $clientService = null, - IJobList $jobList = null) { - if($clientService !== null) { - $this->clientService = $clientService; - } else { - $this->clientService = \OC::$server->getHTTPClientService(); - } - if($jobList !== null) { - $this->jobList = $jobList; - } else { - $this->jobList = \OC::$server->getJobList(); + public function __construct(IClientService $clientService, + IJobList $jobList) { + $this->clientService = $clientService; + $this->jobList = $jobList; + } + + /** + * run the job, then remove it from the jobList + * + * @param JobList $jobList + * @param ILogger $logger + */ + public function execute($jobList, ILogger $logger = null) { + + if ($this->shouldRun($this->argument)) { + parent::execute($jobList, $logger); + $jobList->remove($this, $this->argument); } + } protected function run($argument) { |