From 5ae557a95fcaa87e318fda1c54a5c2dc6437f63b Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 14 Dec 2024 22:36:24 +0800 Subject: [PATCH] core: ProblemSubmit: fix submit_answer problem zip answer upload (#917) Co-authored-by: undefined --- packages/hydrooj/src/handler/problem.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index e29d09b52..9c6898d6e 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -496,15 +496,13 @@ export class ProblemSubmitHandler extends ProblemDetailHandler { if (!file || file.size === 0) throw new ValidationError('code'); const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit; if (file.size > sizeLimit) throw new ValidationError('file'); - const showReadFile = () => { + const shouldReadFile = () => { if (config.type === 'objective') return true; - if (lang === '_') return true; + if (lang === '_') return false; return file.size < lengthLimit && !file.filepath.endsWith('.zip') && !setting.langs[lang].isBinary; }; - if (showReadFile()) { - // TODO submission file shape - code = await readFile(file.filepath, 'utf-8'); - } else { + if (shouldReadFile()) code = await readFile(file.filepath, 'utf-8'); + else { const id = nanoid(); await storage.put(`submission/${this.user._id}/${id}`, file.filepath, this.user._id); files.code = `${this.user._id}/${id}#${file.originalFilename}`;