summaryrefslogtreecommitdiffstats
path: root/lib/private/BackgroundJob/JobList.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/BackgroundJob/JobList.php')
-rw-r--r--lib/private/BackgroundJob/JobList.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index 67b736b8dd9..6761aa282d1 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -35,6 +35,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\AutoloadNotAllowedException;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
+use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -382,4 +383,21 @@ class JobList implements IJobList {
->where($query->expr()->eq('id', $query->createNamedParameter($job->getId()), IQueryBuilder::PARAM_INT));
$query->executeStatement();
}
+
+ public function hasReservedJob(?string $className): bool {
+ $query = $this->connection->getQueryBuilder();
+ $query->select('*')
+ ->from('jobs')
+ ->where($query->expr()->neq('reserved_at', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
+
+ if ($className !== null) {
+ $query->andWhere($query->expr()->eq('class', $query->createNamedParameter($className)));
+ }
+
+ try {
+ return $query->executeQuery()->rowCount() > 0;
+ } catch (Exception $e) {
+ return false;
+ }
+ }
}