mirror of
https://github.com/nextcloud/server.git
synced 2026-03-03 14:01:34 -05:00
fix: delete background jobs by id when cleaning up
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
635f83cc73
commit
b76f4fb2ea
3 changed files with 14 additions and 2 deletions
|
|
@ -127,7 +127,7 @@ class JobList implements IJobList {
|
|||
}
|
||||
}
|
||||
|
||||
protected function removeById(int $id): void {
|
||||
public function removeById(int $id): void {
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$query->delete('jobs')
|
||||
->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
|
||||
|
|
|
|||
|
|
@ -66,6 +66,14 @@ interface IJobList {
|
|||
*/
|
||||
public function remove($job, $argument = null): void;
|
||||
|
||||
/**
|
||||
* Remove a job from the list by id
|
||||
*
|
||||
* @param int $id
|
||||
* @since 30.0.0
|
||||
*/
|
||||
public function removeById(int $id): void;
|
||||
|
||||
/**
|
||||
* check if a job is in the list
|
||||
*
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ abstract class QueuedJob extends Job {
|
|||
* @since 25.0.0
|
||||
*/
|
||||
final public function start(IJobList $jobList): void {
|
||||
$jobList->remove($this, $this->argument);
|
||||
if ($this->id) {
|
||||
$jobList->removeById($this->id);
|
||||
} else {
|
||||
$jobList->remove($this, $this->argument);
|
||||
}
|
||||
parent::start($jobList);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue