添加上传fps文件的支持

This commit is contained in:
undefined committed 2020-09-02 23:17:57 +08:00
1 parent 327fec1fea
commit 7fc721676e
3 files changed
+14 -5

No files matched your search

+4 -4
View File
@@ -85,16 +85,16 @@ class FpsProblemImportHandler extends Handler {
testdata.addFile(`${i + 1}.in`, Buffer.from(p.test_input[i]));
testdata.addFile(`${i + 1}.out`, Buffer.from(p.test_output[i]));
}
const file = path.resolve(os.tmpdir(), 'hydro', `${Math.random()}.zip`);
const f = path.resolve(os.tmpdir(), 'hydro', `${Math.random()}.zip`);
await new Promise((resolve, reject) => {
testdata.writeZip(file, (err) => {
testdata.writeZip(f, (err) => {
if (err) reject(err);
resolve();
});
});
await problem.setTestdata(domainId, pid, file);
await problem.setTestdata(domainId, pid, f);
await problem.edit(domainId, pid, { html: true });
await fs.unlink(file);
await fs.unlink(f);
}
this.response.body = { count: result.fps.item.length };
this.response.redirect = this.url('problem_main');