mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: remove stupid isbinaryfile
This commit is contained in:
1 parent
37ac2f80f7
commit
e7945a104f
2 files changed
+2
-3
No files matched your search
@@ -29,7 +29,6 @@
|
||||
"fs-extra": "^11.1.0",
|
||||
"graphql": "^16.6.0",
|
||||
"graphql-scalars": "1.20.1",
|
||||
"isbinaryfile": "^5.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"koa": "^2.14.1",
|
||||
"koa-body": "^6.0.1",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import AdmZip from 'adm-zip';
|
||||
import { readFile, statSync } from 'fs-extra';
|
||||
import { isBinaryFile } from 'isbinaryfile';
|
||||
import {
|
||||
escapeRegExp, flattenDeep, intersection, pick, uniqBy,
|
||||
} from 'lodash';
|
||||
@@ -524,8 +523,9 @@ 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 (config.type !== 'submit_answer' || (file.size < 65535 && !await isBinaryFile(file.filepath, file.size))) {
|
||||
if (file.size < 65535 && !file.filepath.endsWith('.zip')) {
|
||||
// TODO auto detect & convert encoding
|
||||
// TODO submission file shape
|
||||
code = await readFile(file.filepath, 'utf-8');
|
||||
} else {
|
||||
const id = nanoid();
|
||||
|
||||
Reference in new issue
Block a user