Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let cacheAlbum = async (path: string): Promise => {
// 缓存子图集
let albums: GalleryAlbum[] = await gallery.getAlbums(path, [])
for (let album of albums) {
await cacheAlbum(album.path)
}
// 缓存图片信息
let images: GalleryImage[] = await gallery.getImages(path)
for (let image of images) {
await upyun.getMetaWithCache(image.path)
}
}
export default new schedule.Job('cache', () => {
cacheAlbum('/').catch((e) => logger.error(e))
})
this.jobService.save(job);
});
}
if (scheduler === null) {
return null;
}
const scheduledJob = {jobId: job.id, scheduler: scheduler};
const jobIndex = this.scheduledJobs.findIndex((item) => {
return item.jobId === scheduledJob.jobId;
});
if (jobIndex !== -1) {
if (this.scheduledJobs[jobIndex].scheduler instanceof schedule.Job) {
this.scheduledJobs[jobIndex].scheduler.cancel();
} else {
this.scheduledJobs[jobIndex].scheduler.close();
}
this.scheduledJobs[jobIndex] = scheduledJob;
} else {
this.scheduledJobs.push(scheduledJob);
}
return true;
}