mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core: fix error when pid!==displayId
This commit is contained in:
1 parent
7fd31995ab
commit
37ce0a4f66
3 files changed
+20
-15
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.28.51",
|
"version": "2.28.52",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -36,24 +36,16 @@ const LanguageMap = {
|
|||||||
|
|
||||||
async function syzojSync(info) {
|
async function syzojSync(info) {
|
||||||
const {
|
const {
|
||||||
protocol, host, pid, domainId, docId,
|
protocol, host, domainId, docId,
|
||||||
} = info;
|
} = info;
|
||||||
const body = JSON.parse(info.body);
|
const body = JSON.parse(info.body);
|
||||||
|
const pid = body.meta.id;
|
||||||
const judge = body.judgeInfo;
|
const judge = body.judgeInfo;
|
||||||
const r = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/downloadProblemFiles`)
|
|
||||||
.send({
|
|
||||||
problemId: +pid,
|
|
||||||
type: 'TestData',
|
|
||||||
filenameList: body.testData.map((node) => node.filename),
|
|
||||||
});
|
|
||||||
if (r.body.error) return;
|
|
||||||
const urls = {};
|
|
||||||
const rename = {};
|
const rename = {};
|
||||||
if (judge) {
|
if (judge) {
|
||||||
const config: ProblemConfigFile = {
|
const config: ProblemConfigFile = {
|
||||||
time: `${judge.timeLimit}ms`,
|
time: `${judge.timeLimit}ms`,
|
||||||
memory: `${judge.memoryLimit}m`,
|
memory: `${judge.memoryLimit}m`,
|
||||||
// TODO other config
|
|
||||||
};
|
};
|
||||||
if (judge.extraSourceFiles) {
|
if (judge.extraSourceFiles) {
|
||||||
const user_extra_files = [];
|
const user_extra_files = [];
|
||||||
@@ -85,6 +77,14 @@ async function syzojSync(info) {
|
|||||||
}
|
}
|
||||||
await problem.addTestdata(domainId, docId, 'config.yaml', Buffer.from(yaml.dump(config)));
|
await problem.addTestdata(domainId, docId, 'config.yaml', Buffer.from(yaml.dump(config)));
|
||||||
}
|
}
|
||||||
|
const r = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/downloadProblemFiles`)
|
||||||
|
.send({
|
||||||
|
problemId: pid,
|
||||||
|
type: 'TestData',
|
||||||
|
filenameList: body.testData.map((node) => node.filename),
|
||||||
|
});
|
||||||
|
if (r.body.error) throw new Error(r.body.error.message || r.body.error);
|
||||||
|
const urls = {};
|
||||||
for (const t of r.body.downloadInfo) urls[t.filename] = t.downloadUrl;
|
for (const t of r.body.downloadInfo) urls[t.filename] = t.downloadUrl;
|
||||||
for (const f of body.testData) {
|
for (const f of body.testData) {
|
||||||
const p = new PassThrough();
|
const p = new PassThrough();
|
||||||
@@ -94,12 +94,12 @@ async function syzojSync(info) {
|
|||||||
}
|
}
|
||||||
const a = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/downloadProblemFiles`)
|
const a = await superagent.post(`${protocol}://${host === 'loj.ac' ? 'api.loj.ac.cn' : host}/api/problem/downloadProblemFiles`)
|
||||||
.send({
|
.send({
|
||||||
problemId: +pid,
|
problemId: pid,
|
||||||
type: 'AdditionalFile',
|
type: 'AdditionalFile',
|
||||||
filenameList: body.additionalFiles.map((node) => node.filename),
|
filenameList: body.additionalFiles.map((node) => node.filename),
|
||||||
});
|
});
|
||||||
const aurls = {};
|
const aurls = {};
|
||||||
if (a.body.error) return;
|
if (a.body.error) throw new Error(a.body.error.message || a.body.error);
|
||||||
for (const t of a.body.downloadInfo) aurls[t.filename] = t.downloadUrl;
|
for (const t of a.body.downloadInfo) aurls[t.filename] = t.downloadUrl;
|
||||||
for (const f of body.additionalFiles) {
|
for (const f of body.additionalFiles) {
|
||||||
const p = new PassThrough();
|
const p = new PassThrough();
|
||||||
|
|||||||
@@ -66,9 +66,14 @@ class WorkerService implements BaseService {
|
|||||||
public start() {
|
public start() {
|
||||||
this.consumer = new Consumer(
|
this.consumer = new Consumer(
|
||||||
{ type: 'schedule', subType: { $in: Object.keys(this.handlers) } },
|
{ type: 'schedule', subType: { $in: Object.keys(this.handlers) } },
|
||||||
(doc) => {
|
async (doc) => {
|
||||||
|
try {
|
||||||
logger.debug('Worker task: %o', doc);
|
logger.debug('Worker task: %o', doc);
|
||||||
return this.handlers[doc.subType](doc);
|
await this.handlers[doc.subType](doc);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('Worker task fail: ', e);
|
||||||
|
logger.error('%o', doc);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user