mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
judge: 兼容多目录测试数据
This commit is contained in:
1 parent
c05149f0f9
commit
fe6f0208f5
4 files changed
+13
-10
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.3.3",
|
"version": "2.3.4",
|
||||||
"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,11 +55,11 @@ if (!global.Hydro) {
|
|||||||
}
|
}
|
||||||
const configFile = fs.readFileSync(CONFIG_FILE).toString();
|
const configFile = fs.readFileSync(CONFIG_FILE).toString();
|
||||||
config = { ...config, ...yaml.load(configFile) as any };
|
config = { ...config, ...yaml.load(configFile) as any };
|
||||||
if (fs.existsSync(LANGS_FILE)) config.langs = yaml.load(fs.readFileSync(LANGS_FILE).toString());
|
if (fs.existsSync(LANGS_FILE)) config.langs = fs.readFileSync(LANGS_FILE).toString();
|
||||||
else {
|
else {
|
||||||
log.error('Language file not found, using default.');
|
log.error('Language file not found, using default.');
|
||||||
const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml');
|
const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml');
|
||||||
const content = yaml.load(fs.readFileSync(file).toString()) as any;
|
const content = yaml.load(fs.readFileSync(file).toString()) as any;
|
||||||
config.langs = yaml.load(content.langs.default) as any;
|
config.langs = content.langs.default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,7 @@ class JudgeTask {
|
|||||||
code: string;
|
code: string;
|
||||||
tmpdir: string;
|
tmpdir: string;
|
||||||
clean: Function[];
|
clean: Function[];
|
||||||
|
data: any[];
|
||||||
folder: string;
|
folder: string;
|
||||||
config: any;
|
config: any;
|
||||||
nextId = 1;
|
nextId = 1;
|
||||||
@@ -56,6 +57,7 @@ class JudgeTask {
|
|||||||
this.lang = this.request.lang;
|
this.lang = this.request.lang;
|
||||||
this.code = this.request.code;
|
this.code = this.request.code;
|
||||||
this.config = this.request.config;
|
this.config = this.request.config;
|
||||||
|
this.data = this.request.data;
|
||||||
this.tmpdir = path.resolve(getConfig('tmp_dir'), this.host, this.rid);
|
this.tmpdir = path.resolve(getConfig('tmp_dir'), this.host, this.rid);
|
||||||
this.clean = [];
|
this.clean = [];
|
||||||
fs.ensureDirSync(this.tmpdir);
|
fs.ensureDirSync(this.tmpdir);
|
||||||
@@ -79,7 +81,7 @@ class JudgeTask {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
this.next({ message: { message: e.message, params: e.params, ...argv.debug ? { stack: e.stack } : {} } });
|
this.next({ message: { message: e.message, params: e.params || [], ...argv.debug ? { stack: e.stack } : {} } });
|
||||||
this.end({
|
this.end({
|
||||||
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
||||||
});
|
});
|
||||||
@@ -92,7 +94,7 @@ class JudgeTask {
|
|||||||
|
|
||||||
async doSubmission() {
|
async doSubmission() {
|
||||||
this.stat.cache_start = new Date();
|
this.stat.cache_start = new Date();
|
||||||
this.folder = await this.session.cacheOpen(this.domainId, this.pid, this.next);
|
this.folder = await this.session.cacheOpen(this.domainId, this.pid, this.data, this.next);
|
||||||
this.stat.read_cases = new Date();
|
this.stat.read_cases = new Date();
|
||||||
this.config = await readCases(
|
this.config = await readCases(
|
||||||
this.folder,
|
this.folder,
|
||||||
@@ -192,7 +194,7 @@ export default class Hydro {
|
|||||||
const domainDir = path.join(getConfig('cache_dir'), this.config.host, domainId);
|
const domainDir = path.join(getConfig('cache_dir'), this.config.host, domainId);
|
||||||
const filePath = path.join(domainDir, pid); await fs.ensureDir(filePath);
|
const filePath = path.join(domainDir, pid); await fs.ensureDir(filePath);
|
||||||
if (!files.length) throw new SystemError('Problem data not found.');
|
if (!files.length) throw new SystemError('Problem data not found.');
|
||||||
let etags: Record<string, string>;
|
let etags: Record<string, string> = {};
|
||||||
try {
|
try {
|
||||||
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
|
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
|
||||||
} catch (e) { /* ignore */ }
|
} catch (e) { /* ignore */ }
|
||||||
@@ -210,8 +212,9 @@ export default class Hydro {
|
|||||||
operation: 'get_links',
|
operation: 'get_links',
|
||||||
files: filenames,
|
files: filenames,
|
||||||
});
|
});
|
||||||
for (const name in res.urls) {
|
for (const name in res.data.links) {
|
||||||
const f = await this.axios.get(res.urls[name], { responseType: 'stream' });
|
if (name.includes('/')) await fs.ensureDir(path.join(filePath, name.split('/')[0]));
|
||||||
|
const f = await this.axios.get(res.data.links[name], { responseType: 'stream' });
|
||||||
const w = fs.createWriteStream(path.join(filePath, name));
|
const w = fs.createWriteStream(path.join(filePath, name));
|
||||||
f.data.pipe(w);
|
f.data.pipe(w);
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
|||||||
@@ -147,9 +147,9 @@ class DomainPermissionHandler extends ManageHandler {
|
|||||||
const perms = this.request.body[role] instanceof Array
|
const perms = this.request.body[role] instanceof Array
|
||||||
? this.request.body[role]
|
? this.request.body[role]
|
||||||
: [this.request.body[role]];
|
: [this.request.body[role]];
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
roles[role] = 0n;
|
roles[role] = 0n;
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
||||||
}
|
}
|
||||||
await domain.setRoles(domainId, roles);
|
await domain.setRoles(domainId, roles);
|
||||||
|
|||||||
Reference in new issue
Block a user