mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: contest: fix export_code for submit_answer
This commit is contained in:
1 parent
4958655ac9
commit
58a5cc0f9e
2 files changed
+19
-8
No files matched your search
@@ -527,13 +527,13 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
if (!file || file.size === 0) throw new ValidationError('code');
|
||||
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : 65535;
|
||||
if (file.size > sizeLimit) throw new ValidationError('file');
|
||||
if (file.size > 65535 || await isBinaryFile(file.filepath, file.size)) {
|
||||
if (config.type !== 'submit_answer' || (file.size < 65535 && !await isBinaryFile(file.filepath, file.size))) {
|
||||
// TODO auto detect & convert encoding
|
||||
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}`;
|
||||
} else {
|
||||
// TODO auto detect & convert encoding
|
||||
code = await readFile(file.filepath, 'utf-8');
|
||||
}
|
||||
}
|
||||
const rid = await record.add(
|
||||
|
||||
Reference in new issue
Block a user