mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: import: handle error message for invalid zip
This commit is contained in:
1 parent
cb424c9cac
commit
895d50530a
4 files changed
+24
-4
No files matched your search
@@ -727,7 +727,12 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
if (!this.user.own(this.pdoc, PERM.PERM_EDIT_PROBLEM_SELF)) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
const files = [];
|
||||
if (filename.endsWith('.zip') && type === 'testdata') {
|
||||
const zip = new AdmZip(this.request.files.file.filepath);
|
||||
let zip: AdmZip;
|
||||
try {
|
||||
zip = new AdmZip(this.request.files.file.filepath);
|
||||
} catch (e) {
|
||||
throw new ValidationError('zip', null, e.message);
|
||||
}
|
||||
const entries = zip.getEntries();
|
||||
for (const entry of entries) {
|
||||
if (!entry.name) continue;
|
||||
|
||||
Reference in new issue
Block a user