refactor(server): cron repository (#13988)

This commit is contained in:
Jason Rasmussen 2024-11-07 12:15:54 -05:00 committed by GitHub
parent 2fe6607aea
commit dc2de47204
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 142 additions and 81 deletions

View file

@ -48,12 +48,13 @@ export class LibraryService extends BaseService {
this.watchLibraries = this.lock && watch.enabled;
if (this.lock) {
this.jobRepository.addCronJob(
'libraryScan',
scan.cronExpression,
() => handlePromiseError(this.jobRepository.queue({ name: JobName.LIBRARY_QUEUE_SYNC_ALL }), this.logger),
scan.enabled,
);
this.cronRepository.create({
name: 'libraryScan',
expression: scan.cronExpression,
onTick: () =>
handlePromiseError(this.jobRepository.queue({ name: JobName.LIBRARY_QUEUE_SYNC_ALL }), this.logger),
start: scan.enabled,
});
}
if (this.watchLibraries) {
@ -67,7 +68,11 @@ export class LibraryService extends BaseService {
return;
}
this.jobRepository.updateCronJob('libraryScan', library.scan.cronExpression, library.scan.enabled);
this.cronRepository.update({
name: 'libraryScan',
expression: library.scan.cronExpression,
start: library.scan.enabled,
});
if (library.watch.enabled !== this.watchLibraries) {
// Watch configuration changed, update accordingly