core: add problem config validity check before rejudge

This commit is contained in:
undefined committed 2022-12-17 20:04:43 +08:00
1 parent 632760bedc
commit e3e89ca43f
2 files changed
+5 -1

No files matched your search

+1
View File
@@ -444,6 +444,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
contest: { $ne: new ObjectID('0'.repeat(24)) }, contest: { $ne: new ObjectID('0'.repeat(24)) },
'files.hack': { $exists: false }, 'files.hack': { $exists: false },
}).project({ _id: 1, contest: 1 }).toArray(); }).project({ _id: 1, contest: 1 }).toArray();
if (!this.pdoc.config || typeof this.pdoc.config === 'string') throw new ProblemConfigError();
const priority = await record.submissionPriority(this.user._id, -10000 - rdocs.length * 5 - 50); const priority = await record.submissionPriority(this.user._id, -10000 - rdocs.length * 5 - 50);
await record.reset(domainId, rdocs.map((rdoc) => rdoc._id), true); await record.reset(domainId, rdocs.map((rdoc) => rdoc._id), true);
await Promise.all([ await Promise.all([
+4 -1
View File
@@ -1,7 +1,8 @@
import { omit, pick, throttle } from 'lodash'; import { omit, pick, throttle } from 'lodash';
import { FilterQuery, ObjectID } from 'mongodb'; import { FilterQuery, ObjectID } from 'mongodb';
import { import {
ContestNotAttendedError, ContestNotFoundError, HackRejudgeFailedError, PermissionError, ContestNotAttendedError, ContestNotFoundError, HackRejudgeFailedError,
PermissionError, ProblemConfigError,
ProblemNotFoundError, RecordNotFoundError, UserNotFoundError, ProblemNotFoundError, RecordNotFoundError, UserNotFoundError,
} from '../error'; } from '../error';
import { RecordDoc, Tdoc } from '../interface'; import { RecordDoc, Tdoc } from '../interface';
@@ -191,6 +192,8 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
@param('rid', Types.ObjectID) @param('rid', Types.ObjectID)
async postRejudge(domainId: string, rid: ObjectID) { async postRejudge(domainId: string, rid: ObjectID) {
const pdoc = await problem.get(domainId, this.rdoc.pid);
if (!pdoc?.config || typeof pdoc.config === 'string') throw new ProblemConfigError();
const priority = await record.submissionPriority(this.user._id, -20); const priority = await record.submissionPriority(this.user._id, -20);
const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000'; const isContest = this.rdoc.contest && this.rdoc.contest.toString() !== '000000000000000000000000';
await record.reset(domainId, rid, true); await record.reset(domainId, rid, true);