mirror of
https://github.com/strapi/strapi.git
synced 2025-07-30 20:39:05 +00:00
Change removal logic
This commit is contained in:
parent
680b53c29b
commit
046535397a
@ -28,8 +28,8 @@ const createCronService = () => {
|
|||||||
|
|
||||||
const fnWithStrapi = (...args) => fn({ strapi }, ...args);
|
const fnWithStrapi = (...args) => fn({ strapi }, ...args);
|
||||||
|
|
||||||
const job = new Job(null, fnWithStrapi);
|
const job = new Job(taskValue.name || null, fnWithStrapi);
|
||||||
jobsSpecs.push({ job, options });
|
jobsSpecs.push({ job, options, name: taskValue.name });
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
job.schedule(options);
|
job.schedule(options);
|
||||||
@ -38,9 +38,9 @@ const createCronService = () => {
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
remove(name) {
|
remove(name) {
|
||||||
const matchingJobsSpecs = jobsSpecs.filter(({ options }) => options.name === name);
|
const matchingJobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName === name);
|
||||||
matchingJobsSpecs.forEach(({ job }) => job.cancel());
|
matchingJobsSpecs.forEach(({ job }) => job.cancel());
|
||||||
jobsSpecs = jobsSpecs.filter(({ options }) => options.name !== name);
|
jobsSpecs = jobsSpecs.filter(({ name: jobSpecName }) => jobSpecName !== name);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
start() {
|
start() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user