mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +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",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.3.3",
|
||||
"version": "2.3.4",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -55,11 +55,11 @@ if (!global.Hydro) {
|
||||
}
|
||||
const configFile = fs.readFileSync(CONFIG_FILE).toString();
|
||||
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 {
|
||||
log.error('Language file not found, using default.');
|
||||
const file = path.join(path.dirname(require.resolve('@hydrooj/hydrojudge')), 'setting.yaml');
|
||||
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;
|
||||
tmpdir: string;
|
||||
clean: Function[];
|
||||
data: any[];
|
||||
folder: string;
|
||||
config: any;
|
||||
nextId = 1;
|
||||
@@ -56,6 +57,7 @@ class JudgeTask {
|
||||
this.lang = this.request.lang;
|
||||
this.code = this.request.code;
|
||||
this.config = this.request.config;
|
||||
this.data = this.request.data;
|
||||
this.tmpdir = path.resolve(getConfig('tmp_dir'), this.host, this.rid);
|
||||
this.clean = [];
|
||||
fs.ensureDirSync(this.tmpdir);
|
||||
@@ -79,7 +81,7 @@ class JudgeTask {
|
||||
});
|
||||
} else {
|
||||
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({
|
||||
status: STATUS_SYSTEM_ERROR, score: 0, time_ms: 0, memory_kb: 0,
|
||||
});
|
||||
@@ -92,7 +94,7 @@ class JudgeTask {
|
||||
|
||||
async doSubmission() {
|
||||
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.config = await readCases(
|
||||
this.folder,
|
||||
@@ -192,7 +194,7 @@ export default class Hydro {
|
||||
const domainDir = path.join(getConfig('cache_dir'), this.config.host, domainId);
|
||||
const filePath = path.join(domainDir, pid); await fs.ensureDir(filePath);
|
||||
if (!files.length) throw new SystemError('Problem data not found.');
|
||||
let etags: Record<string, string>;
|
||||
let etags: Record<string, string> = {};
|
||||
try {
|
||||
etags = JSON.parse(fs.readFileSync(path.join(filePath, 'etags')).toString());
|
||||
} catch (e) { /* ignore */ }
|
||||
@@ -210,8 +212,9 @@ export default class Hydro {
|
||||
operation: 'get_links',
|
||||
files: filenames,
|
||||
});
|
||||
for (const name in res.urls) {
|
||||
const f = await this.axios.get(res.urls[name], { responseType: 'stream' });
|
||||
for (const name in res.data.links) {
|
||||
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));
|
||||
f.data.pipe(w);
|
||||
await new Promise((resolve, reject) => {
|
||||
|
||||
@@ -147,9 +147,9 @@ class DomainPermissionHandler extends ManageHandler {
|
||||
const perms = this.request.body[role] instanceof Array
|
||||
? this.request.body[role]
|
||||
: [this.request.body[role]];
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
roles[role] = 0n;
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
for (const r of perms) roles[role] |= 1n << BigInt(r);
|
||||
}
|
||||
await domain.setRoles(domainId, roles);
|
||||
|
||||
Reference in new issue
Block a user