@hydrooj/fps-importer
Advanced tools
Comparing version 1.5.10 to 1.5.11
25
index.ts
@@ -5,4 +5,4 @@ /* eslint-disable no-await-in-loop */ | ||
import { | ||
_, AdmZip, BadRequestError, buildContent, ContentNode, Context, FileTooLargeError, fs, | ||
Handler, PERM, ProblemConfigFile, ProblemModel, ProblemType, SolutionModel, ValidationError, yaml, | ||
_, AdmZip, BadRequestError, buildContent, ContentNode, Context, FileTooLargeError, fs, Handler, | ||
PERM, ProblemConfigFile, ProblemModel, ProblemType, SettingModel, SolutionModel, SystemModel, ValidationError, yaml, | ||
} from 'hydrooj'; | ||
@@ -115,3 +115,3 @@ | ||
const file = await fs.stat(this.request.files.file.filepath); | ||
if (file.size > 64 * 1024 * 1024) throw new FileTooLargeError('64m'); | ||
if (file.size > SystemModel.get('import-fps.limit')) throw new FileTooLargeError(); | ||
const content = fs.readFileSync(this.request.files.file.filepath, 'utf-8'); | ||
@@ -132,3 +132,3 @@ const result = await xml2js.parseStringPromise(content); | ||
const buf = entry.getData(); | ||
if (buf.byteLength > 64 * 1024 * 1024) throw new FileTooLargeError('64m'); | ||
if (buf.byteLength > SystemModel.get('import-fps.limit')) throw new FileTooLargeError(); | ||
const content = buf.toString(); | ||
@@ -151,3 +151,20 @@ const result = await xml2js.parseStringPromise(content); | ||
'From FPS File': '从 FPS 文件导入', | ||
'problem.import.fps.hint1': '我们推荐的最大导入大小为 64MiB,若文件超出此大小,强烈建议您在本机使用 EasyFPSViewer 等工具将其拆分或是移除测试数据后单独上传。', | ||
'problem.import.fps.hint2': '由于 xml 格式无法随机读写,解析需要消耗大量内存,在内存过小的机器上导入大型题目包很可能导致崩溃或死机。', | ||
'problem.import.fps.hint3': '若您确有需要,此限制可在系统设置中更改。我们建议您使用 Hydro 自带的 zip 格式存储或是交换题目。', | ||
}); | ||
ctx.i18n.load('en', { | ||
'From FPS File': 'Import from FPS File', | ||
'problem.import.fps.hint1': 'We recommend that the maximum import size is 64MiB. If the file exceeds this size, \ | ||
we strongly recommend that you use tools such as EasyFPSViewer to split it or remove the testdata and upload it separately on your local machine.', | ||
'problem.import.fps.hint2': 'Since the xml format cannot be read randomly, parsing requires a large amount of memory. \ | ||
Importing a large problem set on a machine with insufficient memory may cause a crash or freeze.', | ||
'problem.import.fps.hint3': 'If you really need it, this limit can be changed in the system settings. \ | ||
We strongly recommend that you use the zip format to store or exchange problemsets.', | ||
}); | ||
ctx.inject(['setting'], (c) => { | ||
c.setting.SystemSetting( | ||
SettingModel.Setting('setting_limits', 'import-fps.limit', 64 * 1024 * 1024, 'text', 'Maximum file size for FPS problemset import'), | ||
); | ||
}); | ||
} |
{ | ||
"name": "@hydrooj/fps-importer", | ||
"version": "1.5.10", | ||
"version": "1.5.11", | ||
"description": "Import FPS problems", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10156
160