mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: also cache by last-modified
This commit is contained in:
1 parent
19df3852b9
commit
df66659c5f
4 files changed
+11
-9
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.6.0",
|
"version": "2.6.1",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -55,8 +55,9 @@ async function read0(folder: string, files: string[], checkFile, cfg) {
|
|||||||
const data = REG.reg.exec(file);
|
const data = REG.reg.exec(file);
|
||||||
const c = { input: file, output: '', id: REG.id(data) };
|
const c = { input: file, output: '', id: REG.id(data) };
|
||||||
for (const func of REG.output) {
|
for (const func of REG.output) {
|
||||||
c.output = func(data);
|
if (cfg.noOutputFile) c.output = '/dev/null';
|
||||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
else c.output = func(data);
|
||||||
|
if (c.output === '/dev/null' || fs.existsSync(path.resolve(folder, c.output))) {
|
||||||
cases.push(c);
|
cases.push(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -114,8 +115,9 @@ async function read1(folder: string, files: string[], checkFile, cfg, rst) {
|
|||||||
const data = REG.reg.exec(file);
|
const data = REG.reg.exec(file);
|
||||||
const c = { input: file, output: '', id: REG.id(data) };
|
const c = { input: file, output: '', id: REG.id(data) };
|
||||||
for (const func of REG.output) {
|
for (const func of REG.output) {
|
||||||
c.output = func(data);
|
if (cfg.noOutputFile) c.output = '/dev/null';
|
||||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
else c.output = func(data);
|
||||||
|
if (c.output === '/dev/null' || fs.existsSync(path.resolve(folder, c.output))) {
|
||||||
if (!subtask[REG.subtask(data)]) {
|
if (!subtask[REG.subtask(data)]) {
|
||||||
subtask[REG.subtask(data)] = [{
|
subtask[REG.subtask(data)] = [{
|
||||||
time: parseTimeMS(cfg.time || '1s'),
|
time: parseTimeMS(cfg.time || '1s'),
|
||||||
|
|||||||
@@ -196,8 +196,8 @@ export default class Hydro {
|
|||||||
const allFiles = new Set<string>();
|
const allFiles = new Set<string>();
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
allFiles.add(file.name);
|
allFiles.add(file.name);
|
||||||
version[file.name] = file.etag;
|
version[file.name] = file.etag + file.lastModified;
|
||||||
if (etags[file.name] !== file.etag) filenames.push(file.name);
|
if (etags[file.name] !== file.etag + file.lastModified) filenames.push(file.name);
|
||||||
}
|
}
|
||||||
for (const name in etags) {
|
for (const name in etags) {
|
||||||
if (!allFiles.has(name)) await fs.rm(path.join(filePath, name));
|
if (!allFiles.has(name)) await fs.rm(path.join(filePath, name));
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ async function postInit() {
|
|||||||
const filenames = new Set<string>();
|
const filenames = new Set<string>();
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
filenames.add(file.name);
|
filenames.add(file.name);
|
||||||
version[file.name] = file.etag;
|
version[file.name] = file.etag + file.lastModified;
|
||||||
if (etags[file.name] !== file.etag) {
|
if (etags[file.name] !== file.etag + file.lastModified) {
|
||||||
await storage.get(`problem/${domainId}/${pid}/testdata/${file.name}`, path.join(filePath, file.name));
|
await storage.get(`problem/${domainId}/${pid}/testdata/${file.name}`, path.join(filePath, file.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user