mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: import.syzoj: del tmp file
This commit is contained in:
1 parent
4d9a7a6bb4
commit
3dcc6d2aa2
2 files changed
+24
-20
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.15.28",
|
"version": "2.15.29",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -102,26 +102,30 @@ class ProblemImportSYZOJHandler extends Handler {
|
|||||||
const r = download(`${url}testdata/download`);
|
const r = download(`${url}testdata/download`);
|
||||||
const file = path.resolve(os.tmpdir(), 'hydro', `import_${domainId}_${docId}.zip`);
|
const file = path.resolve(os.tmpdir(), 'hydro', `import_${domainId}_${docId}.zip`);
|
||||||
const w = fs.createWriteStream(file);
|
const w = fs.createWriteStream(file);
|
||||||
await new Promise((resolve, reject) => {
|
try {
|
||||||
w.on('finish', resolve);
|
await new Promise((resolve, reject) => {
|
||||||
w.on('error', reject);
|
w.on('finish', resolve);
|
||||||
r.pipe(w);
|
w.on('error', reject);
|
||||||
});
|
r.pipe(w);
|
||||||
const zip = new AdmZip(file);
|
});
|
||||||
const entries = zip.getEntries();
|
const zip = new AdmZip(file);
|
||||||
for (const entry of entries) {
|
const entries = zip.getEntries();
|
||||||
// eslint-disable-next-line no-await-in-loop
|
for (const entry of entries) {
|
||||||
await problem.addTestdata(domainId, docId, entry.entryName, entry.getData());
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await problem.addTestdata(domainId, docId, entry.entryName, entry.getData());
|
||||||
|
}
|
||||||
|
const filename = p.file_io_input_name ? p.file_io_input_name?.split('.')[0] : null;
|
||||||
|
await problem.edit(domainId, docId, {
|
||||||
|
config: {
|
||||||
|
time: `${p.time_limit}ms`,
|
||||||
|
memory: `${p.memory_limit}m`,
|
||||||
|
filename,
|
||||||
|
type: p.type === 'traditional' ? 'default' : p.type,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
fs.unlinkSync(file);
|
||||||
}
|
}
|
||||||
const filename = p.file_io_input_name ? p.file_io_input_name?.split('.')[0] : null;
|
|
||||||
await problem.edit(domainId, docId, {
|
|
||||||
config: {
|
|
||||||
time: `${p.time_limit}ms`,
|
|
||||||
memory: `${p.memory_limit}m`,
|
|
||||||
filename,
|
|
||||||
type: p.type === 'traditional' ? 'default' : p.type,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return docId;
|
return docId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user