judge: remove low-performance api

This commit is contained in:
undefined committed 2022-09-06 13:02:46 +08:00
1 parent 9d0aeebe12
commit ce8627bce8
6 files changed
+36 -49

No files matched your search

+5 -3
View File
@@ -53,7 +53,7 @@ const session = {
if (!files?.length) throw new FormatError('Problem data not found.');
let etags: Record<string, string> = {};
try {
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
etags = JSON.parse(await fs.readFile(path.join(filePath, 'etags'), 'utf-8'));
} catch (e) { /* ignore */ }
const version = {};
const filenames = new Set<string>();
@@ -67,8 +67,10 @@ const session = {
for (const name in etags) {
if (!filenames.has(name) && fs.existsSync(path.join(filePath, name))) await fs.remove(path.join(filePath, name));
}
fs.writeFileSync(path.join(filePath, 'etags'), JSON.stringify(version));
fs.writeFileSync(path.join(filePath, 'lastUsage'), Date.now().toString());
await Promise.all([
fs.writeFile(path.join(filePath, 'etags'), JSON.stringify(version)),
fs.writeFile(path.join(filePath, 'lastUsage'), Date.now().toString()),
]);
await processTestdata(filePath);
return filePath;
},
+3 -3
View File
@@ -64,7 +64,7 @@ export default class Hydro {
if (!files?.length) throw new FormatError('Problem data not found.');
let etags: Record<string, string> = {};
try {
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
etags = JSON.parse(await fs.readFile(path.join(filePath, 'etags'), 'utf-8'));
} catch (e) { /* ignore */ }
const version = {};
const filenames = [];
@@ -102,10 +102,10 @@ export default class Hydro {
}
queue.start();
await Promise.all(tasks);
fs.writeFileSync(path.join(filePath, 'etags'), JSON.stringify(version));
await fs.writeFile(path.join(filePath, 'etags'), JSON.stringify(version));
await processTestdata(filePath);
}
fs.writeFileSync(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
await fs.writeFile(path.join(filePath, 'lastUsage'), new Date().getTime().toString());
return filePath;
}