judge: auto-remove extra files (#104)

This commit is contained in:
undefined committed 2021-04-20 21:56:31 +08:00
1 parent c977a51de9
commit a7fd32cac9
6 files changed
+26 -2

No files matched your search

+1
View File
@@ -394,6 +394,7 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
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 (filename.includes('/')) throw new ValidationError('filename', 'Bad filename');
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);