Fix prune scheduler not being started

This commit is contained in:
Chrystian Huot 2020-07-02 09:39:47 -04:00
parent 2a14073911
commit 4256457f2d

View file

@ -50,11 +50,26 @@ class Controller {
this.ffmpeg = !spawnSync('ffmpeg', ['-version']).error;
this.pruneInterval = undefined;
if (!this.ffmpeg) {
console.warn('ffmpeg is missing, no audio conversion possible.');
}
if (this.app.config.pruneDays > 0) {
this.pruneInterval = setInterval(() => {
const now = new Date();
this.app.models.call.destroy({
where: {
dateTime: {
[Op.lt]: new Date(now.getFullYear(), now.getMonth(), now.getDate() - this.app.config.pruneDays),
},
},
});
}, 15 * 60 * 1000);
} else {
this.pruneInterval = undefined;
}
}
authenticate(token) {
@ -512,30 +527,6 @@ class Controller {
}
}
pruneSchedulerStart() {
if (this.app.config.pruneDays > 0) {
this.pruneInterval = setInterval(() => {
const now = new Date();
this.app.models.call.destroy({
where: {
dateTime: {
[Op.lt]: new Date(now.getFullYear(), now.getMonth(), now.getDate() - this.app.config.pruneDays),
},
},
});
}, 15 * 60 * 1000);
}
}
pruneSchedulerStop() {
if (this.pruneInterval) {
clearInterval(this.pruneInterval);
this.pruneInterval = undefined;
}
}
validateApiKey(apiKey, system, talkgroup) {
const scope = this.getScope(apiKey, this.app.config.apiKeys);