mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: bug fixes
This commit is contained in:
1 parent
fe0cd78db7
commit
5d0676a5d9
6 files changed
+17
-17
No files matched your search
@@ -88,8 +88,8 @@ export const runFlow = async (ctx: Context, task: Task) => {
|
|||||||
};
|
};
|
||||||
const runner = task.judgeCase(subtask.cases.find((i) => i.input.endsWith(ctx.meta.hackRejudge)));
|
const runner = task.judgeCase(subtask.cases.find((i) => i.input.endsWith(ctx.meta.hackRejudge)));
|
||||||
const res = await runner(ctx, ctxSubtask, runner);
|
const res = await runner(ctx, ctxSubtask, runner);
|
||||||
if (res) ctx.next(res);
|
if (res) ctx.next({ case: res });
|
||||||
if (res.status !== STATUS.STATUS_ACCEPTED) {
|
if (res?.status !== STATUS.STATUS_ACCEPTED) {
|
||||||
const totalScore = Math.sum(ctx.config.subtasks.map((i) => i.score));
|
const totalScore = Math.sum(ctx.config.subtasks.map((i) => i.score));
|
||||||
ctx.end({
|
ctx.end({
|
||||||
status: STATUS.STATUS_HACKED,
|
status: STATUS.STATUS_HACKED,
|
||||||
|
|||||||
@@ -28,16 +28,17 @@ export default class Hydro {
|
|||||||
this.config.cookie = this.config.cookie || '';
|
this.config.cookie = this.config.cookie || '';
|
||||||
this.config.last_update_at = this.config.last_update_at || 0;
|
this.config.last_update_at = this.config.last_update_at || 0;
|
||||||
if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`;
|
if (!this.config.server_url.startsWith('http')) this.config.server_url = `http://${this.config.server_url}`;
|
||||||
if (!this.config.server_url.endsWith('/')) this.config.server_url = `${this.config.server_url}/`;
|
|
||||||
this.getLang = this.getLang.bind(this);
|
this.getLang = this.getLang.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get(url) {
|
get(url: string) {
|
||||||
return superagent.get(this.config.server_url + url).set('Cookie', this.config.cookie);
|
url = new URL(url, this.config.server_url).toString();
|
||||||
|
return superagent.get(url).set('Cookie', this.config.cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
post(url, data) {
|
post(url: string, data: any) {
|
||||||
return superagent.post(this.config.server_url + url).send(data)
|
url = new URL(url, this.config.server_url).toString();
|
||||||
|
return superagent.post(url).send(data)
|
||||||
.set('Cookie', this.config.cookie)
|
.set('Cookie', this.config.cookie)
|
||||||
.set('Accept', 'application/json');
|
.set('Accept', 'application/json');
|
||||||
}
|
}
|
||||||
@@ -51,7 +52,7 @@ export default class Hydro {
|
|||||||
async cacheOpen(source: string, files: any[], next?) {
|
async cacheOpen(source: string, files: any[], next?) {
|
||||||
await Lock.acquire(`${this.config.host}/${source}`);
|
await Lock.acquire(`${this.config.host}/${source}`);
|
||||||
try {
|
try {
|
||||||
return this._cacheOpen(source, files, next);
|
return await this._cacheOpen(source, files, next);
|
||||||
} finally {
|
} finally {
|
||||||
Lock.release(`${this.config.host}/${source}`);
|
Lock.release(`${this.config.host}/${source}`);
|
||||||
}
|
}
|
||||||
@@ -79,7 +80,7 @@ export default class Hydro {
|
|||||||
}
|
}
|
||||||
if (filenames.length) {
|
if (filenames.length) {
|
||||||
log.info(`Getting problem data: ${this.config.host}/${source}`);
|
log.info(`Getting problem data: ${this.config.host}/${source}`);
|
||||||
if (next) next({ message: 'Syncing testdata, please wait...' });
|
next?.({ message: 'Syncing testdata, please wait...' });
|
||||||
await this.ensureLogin();
|
await this.ensureLogin();
|
||||||
const res = await this.post(`/d/${domainId}/judge/files`, {
|
const res = await this.post(`/d/${domainId}/judge/files`, {
|
||||||
pid: +pid,
|
pid: +pid,
|
||||||
@@ -140,7 +141,7 @@ export default class Hydro {
|
|||||||
|
|
||||||
getNext(t: JudgeTask) {
|
getNext(t: JudgeTask) {
|
||||||
return (data: Partial<JudgeResultBody>) => {
|
return (data: Partial<JudgeResultBody>) => {
|
||||||
log.debug('Next: %d %o', data);
|
log.debug('Next: %o', data);
|
||||||
this.send(t.request.rid, 'next', data);
|
this.send(t.request.rid, 'next', data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -207,7 +208,7 @@ export default class Hydro {
|
|||||||
|
|
||||||
async ensureLogin() {
|
async ensureLogin() {
|
||||||
try {
|
try {
|
||||||
const res = await this.get('judge/files');
|
const res = await this.get('judge/files').set('Accept', 'application/json');
|
||||||
// Redirected to /login
|
// Redirected to /login
|
||||||
if (res.body.url) await this.login();
|
if (res.body.url) await this.login();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import { STATUS } from '@hydrooj/utils/lib/status';
|
|||||||
import type {
|
import type {
|
||||||
FileInfo, JudgeMeta, JudgeRequest, JudgeResultBody,
|
FileInfo, JudgeMeta, JudgeRequest, JudgeResultBody,
|
||||||
} from 'hydrooj';
|
} from 'hydrooj';
|
||||||
import { Logger } from 'hydrooj/src/logger';
|
|
||||||
import readCases from './cases';
|
import readCases from './cases';
|
||||||
import { getConfig } from './config';
|
import { getConfig } from './config';
|
||||||
import { CompileError, FormatError } from './error';
|
import { CompileError, FormatError } from './error';
|
||||||
import { NextFunction, ParsedConfig } from './interface';
|
import { NextFunction, ParsedConfig } from './interface';
|
||||||
import judge from './judge';
|
import judge from './judge';
|
||||||
|
import { Logger } from './log';
|
||||||
import { CopyInFile } from './sandbox';
|
import { CopyInFile } from './sandbox';
|
||||||
import * as tmpfs from './tmpfs';
|
import * as tmpfs from './tmpfs';
|
||||||
import { compilerText, Lock, md5 } from './utils';
|
import { compilerText, Lock, md5 } from './utils';
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async cleanup() {
|
async cleanup() {
|
||||||
logger.info('Judge daemon disconnected from ', this.ip);
|
logger.info('Judge daemon disconnected from ', this.request.ip);
|
||||||
bus.off('system/setting', this.sendLanguageConfig);
|
bus.off('system/setting', this.sendLanguageConfig);
|
||||||
if (this.processing) {
|
if (this.processing) {
|
||||||
await record.reset(this.processing.domainId, this.processing.rid, false);
|
await record.reset(this.processing.domainId, this.processing.rid, false);
|
||||||
|
|||||||
@@ -435,8 +435,7 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
|||||||
pid,
|
pid,
|
||||||
contest: { $ne: new ObjectID('0'.repeat(24)) },
|
contest: { $ne: new ObjectID('0'.repeat(24)) },
|
||||||
status: { $ne: [STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL] },
|
status: { $ne: [STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL] },
|
||||||
})
|
}).project({ _id: 1, contest: 1 }).toArray();
|
||||||
.project({ _id: 1, contest: 1 }).toArray();
|
|
||||||
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
|
const priority = await record.submissionPriority(this.user._id, -rdocs.length * 5 - 50);
|
||||||
await Promise.all(rdocs.map(
|
await Promise.all(rdocs.map(
|
||||||
(doc) => record.reset(domainId, doc._id, true)
|
(doc) => record.reset(domainId, doc._id, true)
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ class RecordDetailHandler extends Handler {
|
|||||||
@param('rid', Types.ObjectID)
|
@param('rid', Types.ObjectID)
|
||||||
async postRejudge(domainId: string, rid: ObjectID) {
|
async postRejudge(domainId: string, rid: ObjectID) {
|
||||||
this.checkPerm(PERM.PERM_REJUDGE);
|
this.checkPerm(PERM.PERM_REJUDGE);
|
||||||
if ([STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL].find((i) => i === this.rdoc.status)) {
|
if ([STATUS.STATUS_HACK_SUCCESSFUL, STATUS.STATUS_HACK_UNSUCCESSFUL].includes(this.rdoc.status)) {
|
||||||
throw new ForbiddenError('Cannot rejudge hack record.');
|
throw new ForbiddenError('Cannot rejudge a hack record.');
|
||||||
}
|
}
|
||||||
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';
|
||||||
|
|||||||
Reference in new issue
Block a user