mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-21 01:46:28 +08:00
ui: file upload support
This commit is contained in:
1 parent
2539dfa412
commit
595f28b1df
5 files changed
+64
-22
No files matched your search
@@ -389,10 +389,11 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
this.response.body.links = links;
|
||||
}
|
||||
|
||||
@post('filename', Types.Name)
|
||||
@post('type', Types.Content, true)
|
||||
@post('filename', Types.Name, true)
|
||||
@post('type', Types.Range(['testdata', 'additional_file']), true)
|
||||
async postUploadFile(domainId: string, filename: string, type = 'testdata') {
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
if (!filename) filename = this.request.files.file.name || String.random(16);
|
||||
if (this.pdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
if (filename.endsWith('.zip')) {
|
||||
const zip = new AdmZip(this.request.files.file.path);
|
||||
|
||||
@@ -21,8 +21,8 @@ export async function parseConfig(config: string | ProblemConfig = {}) {
|
||||
let cfg: ProblemConfig = {};
|
||||
if (typeof config === 'string' && config.length) {
|
||||
// TODO should validate here?
|
||||
cfg = await readYamlCases(load(config) as Record<string, any>) as ProblemConfig;
|
||||
} else if (typeof config === 'object') cfg = config;
|
||||
cfg = await readYamlCases(load(config) as Record<string, any>);
|
||||
} else if (typeof config === 'object') cfg = await readYamlCases(config);
|
||||
if (cfg.subtasks.length) {
|
||||
for (const subtask of cfg.subtasks) {
|
||||
result.memoryMax = Math.max(result.memoryMax, subtask.memory);
|
||||
|
||||
Reference in new issue
Block a user