core: 修复错误

* 无法下载测试数据的问题
* 无法导出作业成绩单的问题
* cli 模式无法载入的问题
* syzoj 导入跳转错误的问题
pull/56/head
undefined 4 years ago
parent 66639b14de
commit f0b9bee937

@ -71,6 +71,7 @@ async function postInit() {
}
async function cacheOpen(domainId: string, pid: string, files: any[]) {
console.log(files);
const filePath = path.join(getConfig('cache_dir'), domainId, pid);
await fs.ensureDir(filePath);
if (!files.length) throw new SystemError('Problem data not found.');
@ -82,7 +83,7 @@ async function postInit() {
for (const file of files) {
version[file.name] = file.etag;
if (etags[file.name] !== file.etag) {
await storage.get(`${file.prefix}${file.name}`, path.join(filePath, file.name));
await storage.get(`problem/${domainId}/${pid}/testdata/${file.name}`, path.join(filePath, file.name));
}
}
fs.writeFileSync(path.join(filePath, 'etags'), JSON.stringify(version));

@ -538,6 +538,7 @@ problem_create: 创建题目
problem_detail: 题目详情
problem_edit: 编辑题目
problem_files: 题目文件
problem_import_syzoj: 从 SYZOJ 导入题目
problem_import: 导入题目
problem_main: 题库
problem_settings: 题目设置

@ -8,7 +8,6 @@ import {
import options from '../options';
import * as bus from '../service/bus';
import db from '../service/db';
import storage from '../service/storage';
const COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
const ARR = /=>.*$/mg;
@ -26,6 +25,9 @@ async function cli() {
if (!global.Hydro.model[modelName]) {
return console.error(`Model ${modelName} doesn't exist.`);
}
if (!func) {
return console.log(Object.keys(global.Hydro.model[modelName]));
}
if (!global.Hydro.model[modelName][func]) {
return console.error(`Function ${func} doesn't exist in model ${modelName}.`);
}
@ -65,6 +67,7 @@ export async function load() {
const sopts = {
endPoint, accessKey, secretKey, bucket, region, endPointForUser, endPointForJudge,
};
const storage = require('../service/storage');
await storage.start(sopts);
for (const i of builtinLib) require(`../lib/${i}`);
await lib(pending, fail);

@ -370,7 +370,7 @@ class HomeworkScoreboardDownloadHandler extends HomeworkHandler {
html: (rows) => this.renderHTML('contest_scoreboard_download_html.html', { rows }),
};
if (!getContent[ext]) throw new ValidationError('ext');
const [, rows] = await this.getScoreboard(domainId, tid, true, document.TYPE_CONTEST);
const [, rows] = await this.getScoreboard(domainId, tid, true, document.TYPE_HOMEWORK);
this.binary(await getContent[ext](rows), `${this.tdoc.title}.${ext}`);
}
}

@ -247,12 +247,12 @@ class ProblemImportSYZOJHandler extends Handler {
domainId, targetPid, hidden,
protocol, host, pid, false,
);
this.response.body = { pid: pid || docId };
this.response.redirect = this.url('problem_settings', { pid: pid || docId });
this.response.body = { pid: targetPid || docId };
this.response.redirect = this.url('problem_settings', { pid: targetPid || docId });
} else {
const docId = await this.v2(domainId, targetPid, hidden, url);
this.response.body = { pid: pid || docId };
this.response.redirect = this.url('problem_settings', { pid: pid || docId });
this.response.body = { pid: targetPid || docId };
this.response.redirect = this.url('problem_settings', { pid: targetPid || docId });
}
}
}

@ -185,9 +185,7 @@ declare module './model/problem' {
difficultyAdmin?: number,
difficultySetting?: any,
/**
* @deprecated
*/
/** @deprecated */
config: any,
}
}

@ -18,9 +18,7 @@ export const PERM = {
// Problem and Record
PERM_CREATE_PROBLEM: 1n << 4n,
PERM_EDIT_PROBLEM: 1n << 5n,
/**
* @deprecated
*/
/** @deprecated */
PERM_EDIT_PROBLEM_SELF: 1n << 6n,
PERM_VIEW_PROBLEM: 1n << 7n,
PERM_VIEW_PROBLEM_HIDDEN: 1n << 8n,
@ -237,21 +235,13 @@ export const PRIV = {
PRIV_DEFAULT: 0,
PRIV_NEVER: 1 << 20,
/**
* @deprecated
*/
/** @deprecated */
PRIV_CREATE_FILE: 1 << 16,
/**
* @deprecated
*/
/** @deprecated */
PRIV_UNLIMITED_QUOTA: 1 << 17,
/**
* @deprecated
*/
/** @deprecated */
PRIV_DELETE_FILE: 1 << 18,
/**
* @deprecated
*/
/** @deprecated */
PRIV_DELETE_FILE_SELF: 1 << 19,
};

@ -304,7 +304,7 @@ export class HandlerCommon {
try {
const { anchor } = args;
if (args.domainId) name += '_with_domainId';
else if (this.domain.host !== this.request.host && this.domainId !== 'system') {
else if (this.domain?.host !== this.request.host && this.domainId !== 'system') {
name += '_with_domainId';
args.domainId = this.domainId;
}

Loading…
Cancel
Save