fix: did not quit when job is already workingx

This commit is contained in:
alikia2x (寒寒) 2025-03-24 01:10:27 +08:00
parent 723b6090c4
commit 0455abce2e
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6

View File

@ -133,7 +133,11 @@ export const collectMilestoneSnapshotsWorker = async (_job: Job) => {
export const regularSnapshotsWorker = async (_job: Job) => {
const client = await db.connect();
const startedAt = Date.now();
await lockManager.acquireLock("dispatchRegularSnapshots");
if (await lockManager.isLocked("dispatchRegularSnapshots")) {
logger.log("dispatchRegularSnapshots is already running", "mq");
return;
}
await lockManager.acquireLock("dispatchRegularSnapshots", 30 * 60);
try {
const aids = await getVideosWithoutActiveSnapshotSchedule(client);
for (const rawAid of aids) {