Browse Source

Fix custom test

pull/6/head
Menci 7 years ago
parent
commit
a09a59e56a
  1. 2
      modules/api_v2.js
  2. 4
      modules/problem.js

2
modules/api_v2.js

@ -138,7 +138,7 @@ app.apiRouter.post('/api/v2/judge/peek', async (req, res) => {
judge_id: custom_test.id,
code: custom_test.code,
language: custom_test.language,
testdata: custom_test.problem.id,
input_file: (await require('fs-extra').readFileAsync(custom_test.input_file)).toString(),
time_limit: custom_test.problem.time_limit,
memory_limit: custom_test.problem.memory_limit,
file_io: custom_test.problem.file_io,

4
modules/problem.js

@ -833,7 +833,7 @@ app.post('/problem/:id/custom-test', app.multer.fields([{ name: 'code_upload', m
if (!await problem.isAllowedUseBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。');
let filepath;
if (req.files['input_file'][0]) {
if (req.files['input_file']) {
if (req.files['input_file'][0].size > syzoj.config.limit.custom_test_input) throw new ErrorMessage('输入数据过长。');
filepath = req.files['input_file'][0].path;
} else {
@ -843,7 +843,7 @@ app.post('/problem/:id/custom-test', app.multer.fields([{ name: 'code_upload', m
}
let code;
if (req.files['code_upload'][0]) {
if (req.files['code_upload']) {
if (req.files['code_upload'][0].size > syzoj.config.limit.submit_code) throw new ErrorMessage('代码过长。');
code = (await require('fs-extra').readFileAsync(req.files['code_upload'][0].path)).toString();
} else {

Loading…
Cancel
Save