From a09a59e56a861659526fdc76af94fb273b7d5947 Mon Sep 17 00:00:00 2001 From: Menci Date: Fri, 14 Jul 2017 08:24:32 +0800 Subject: [PATCH] Fix custom test --- modules/api_v2.js | 2 +- modules/problem.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/api_v2.js b/modules/api_v2.js index 8a00142..e1934ea 100644 --- a/modules/api_v2.js +++ b/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, diff --git a/modules/problem.js b/modules/problem.js index 1aaa45d..80d00a8 100644 --- a/modules/problem.js +++ b/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 {