Skip to content

Commit

Permalink
fix: forcibly remove import locks if stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
zkrising committed Aug 31, 2024
1 parent 8e118ac commit de72237
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/src/lib/score-import/framework/import-locks/lock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import db from "external/mongo/db";
import { ONE_HOUR } from "lib/constants/time";
import { ONE_DAY, ONE_HOUR } from "lib/constants/time";
import CreateLogCtx from "lib/logger/logger";
import type { integer } from "tachi-common";

Expand All @@ -24,6 +24,17 @@ export async function CheckAndSetOngoingImportLock(userID: integer) {
locked: false,
lockedAt: null,
});
} else if (lockExists.locked && lockExists.lockedAt! + ONE_DAY < Date.now()) {
logger.warn(`Removed import lock for ${userID} as it is ostensibly stuck.`);
await db["import-locks"].update(
{
userID,
},
{
locked: false,
lockedAt: null,
}
);
}

const lockWasSet = await db["import-locks"].findOneAndUpdate(
Expand Down

0 comments on commit de72237

Please sign in to comment.