mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: use FileTooLargeError for ProblemSubmitHandler
This commit is contained in:
1 file changed
+2
-2
@@ -11,7 +11,7 @@ import { sortFiles, streamToBuffer } from '@hydrooj/utils/lib/utils';
|
|||||||
import type { Context } from '../context';
|
import type { Context } from '../context';
|
||||||
import {
|
import {
|
||||||
BadRequestError, ContestNotAttendedError, ContestNotEndedError, ContestNotFoundError, ContestNotLiveError,
|
BadRequestError, ContestNotAttendedError, ContestNotEndedError, ContestNotFoundError, ContestNotLiveError,
|
||||||
FileLimitExceededError, HackFailedError, NoProblemError, NotFoundError,
|
FileLimitExceededError, FileTooLargeError, HackFailedError, NoProblemError, NotFoundError,
|
||||||
PermissionError, ProblemAlreadyExistError, ProblemAlreadyUsedByContestError, ProblemConfigError,
|
PermissionError, ProblemAlreadyExistError, ProblemAlreadyUsedByContestError, ProblemConfigError,
|
||||||
ProblemIsReferencedError, ProblemNotAllowCopyError, ProblemNotAllowLanguageError, ProblemNotAllowPretestError,
|
ProblemIsReferencedError, ProblemNotAllowCopyError, ProblemNotAllowLanguageError, ProblemNotAllowPretestError,
|
||||||
ProblemNotFoundError, RecordNotFoundError, SolutionNotFoundError, ValidationError,
|
ProblemNotFoundError, RecordNotFoundError, SolutionNotFoundError, ValidationError,
|
||||||
@@ -497,7 +497,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
|
|||||||
const file = this.request.files?.file;
|
const file = this.request.files?.file;
|
||||||
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 FileTooLargeError('file');
|
||||||
const shouldReadFile = () => {
|
const shouldReadFile = () => {
|
||||||
if (config.type === 'objective') return true;
|
if (config.type === 'objective') return true;
|
||||||
if (lang === '_') return false;
|
if (lang === '_') return false;
|
||||||
|
|||||||
Reference in new issue
Block a user