mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: ProblemSubmit: add shouldReadFile check
This commit is contained in:
1 file changed
+6
-1
@@ -499,7 +499,12 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
|||||||
if (!file || file.size === 0) throw new ValidationError('code');
|
if (!file || file.size === 0) throw new ValidationError('code');
|
||||||
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit;
|
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit;
|
||||||
if (file.size > sizeLimit) throw new ValidationError('file');
|
if (file.size > sizeLimit) throw new ValidationError('file');
|
||||||
if (file.size < lengthLimit && !file.filepath.endsWith('.zip') && !setting.langs[lang].isBinary) {
|
const showReadFile = () => {
|
||||||
|
if (config.type === 'objective') return true;
|
||||||
|
if (lang === '_') return true;
|
||||||
|
return file.size < lengthLimit && !file.filepath.endsWith('.zip') && !setting.langs[lang].isBinary;
|
||||||
|
};
|
||||||
|
if (showReadFile()) {
|
||||||
// TODO submission file shape
|
// TODO submission file shape
|
||||||
code = await readFile(file.filepath, 'utf-8');
|
code = await readFile(file.filepath, 'utf-8');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user