Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichaIng <micha@dietpi.com>2022-01-12 18:02:12 +0300
committerGitHub <noreply@github.com>2022-01-12 18:02:12 +0300
commit12d92650fd67f11b5390d039e8b812a33f120ca9 (patch)
tree3548e369578a96e335628278a9b750158e3d1582 /lib
parent29a3f2cd232b81ebaaa0667d6997d02264407a04 (diff)
parent96e520584a4888ae26086c626c8dc58de47572fe (diff)
Merge pull request #30622 from nextcloud/backport/30358/stable22
[stable22] Reset job disabling timer on adding the job again
Diffstat (limited to 'lib')
-rw-r--r--lib/private/BackgroundJob/JobList.php32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php
index f3b96dcbb7b..693c7af5ea1 100644
--- a/lib/private/BackgroundJob/JobList.php
+++ b/lib/private/BackgroundJob/JobList.php
@@ -65,28 +65,34 @@ class JobList implements IJobList {
* @param mixed $argument
*/
public function add($job, $argument = null) {
- if (!$this->has($job, $argument)) {
- if ($job instanceof IJob) {
- $class = get_class($job);
- } else {
- $class = $job;
- }
+ if ($job instanceof IJob) {
+ $class = get_class($job);
+ } else {
+ $class = $job;
+ }
- $argument = json_encode($argument);
- if (strlen($argument) > 4000) {
- throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)');
- }
+ $argumentJson = json_encode($argument);
+ if (strlen($argumentJson) > 4000) {
+ throw new \InvalidArgumentException('Background job arguments can\'t exceed 4000 characters (json encoded)');
+ }
- $query = $this->connection->getQueryBuilder();
+ $query = $this->connection->getQueryBuilder();
+ if (!$this->has($job, $argument)) {
$query->insert('jobs')
->values([
'class' => $query->createNamedParameter($class),
- 'argument' => $query->createNamedParameter($argument),
+ 'argument' => $query->createNamedParameter($argumentJson),
'last_run' => $query->createNamedParameter(0, IQueryBuilder::PARAM_INT),
'last_checked' => $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT),
]);
- $query->execute();
+ } else {
+ $query->update('jobs')
+ ->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT))
+ ->set('last_checked', $query->createNamedParameter($this->timeFactory->getTime(), IQueryBuilder::PARAM_INT))
+ ->where($query->expr()->eq('class', $query->createNamedParameter($class)))
+ ->andWhere($query->expr()->eq('argument', $query->createNamedParameter($argumentJson)));
}
+ $query->executeStatement();
}
/**