mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
judge: update files api endpoint
This commit is contained in:
3 files changed
+10
-13
No files matched your search
@@ -125,7 +125,7 @@ export default class Hydro implements Session {
|
||||
|
||||
async fetchFile(name: string) {
|
||||
name = name.split('#')[0];
|
||||
const res = await this.post('judge/code', { id: name });
|
||||
const res = await this.post('judge/files', { id: name });
|
||||
const target = path.join(getConfig('tmp_dir'), name.replace(/\//g, '_'));
|
||||
const w = fs.createWriteStream(target);
|
||||
this.get(res.body.url).pipe(w);
|
||||
|
||||
@@ -153,9 +153,14 @@ export class JudgeFilesDownloadHandler extends Handler {
|
||||
}
|
||||
|
||||
noCheckPermView = true;
|
||||
@post('files', Types.Set)
|
||||
@post('pid', Types.UnsignedInt)
|
||||
async post(domainId: string, files: Set<string>, pid: number) {
|
||||
@post('id', Types.String, true)
|
||||
@post('files', Types.Set, true)
|
||||
@post('pid', Types.UnsignedInt, true)
|
||||
async post(domainId: string, id: string, files: Set<string>, pid: number) {
|
||||
if (id) {
|
||||
this.response.body = { url: await storage.signDownloadLink(`submission/${id}`, 'code', true, 'judge') };
|
||||
return;
|
||||
}
|
||||
const pdoc = await problem.get(domainId, pid);
|
||||
if (!pdoc) this.response.body.links = null;
|
||||
const links = {};
|
||||
@@ -170,13 +175,6 @@ export class JudgeFilesDownloadHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
export class SubmissionDataDownloadHandler extends Handler {
|
||||
@post('id', Types.String)
|
||||
async post(domainId: string, id: string) {
|
||||
this.response.body = { url: await storage.signDownloadLink(`submission/${id}`, 'code', true, 'judge') };
|
||||
}
|
||||
}
|
||||
|
||||
export async function processJudgeFileCallback(rid: ObjectId, filename: string, filePath: string) {
|
||||
const rdoc = await record.get(rid);
|
||||
const [pdoc, udoc] = await Promise.all([
|
||||
@@ -301,7 +299,6 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
||||
export async function apply(ctx) {
|
||||
ctx.Route('judge_files_download', '/judge/files', JudgeFilesDownloadHandler, builtin.PRIV.PRIV_JUDGE);
|
||||
ctx.Route('judge_files_upload', '/judge/upload', JudgeFileUpdateHandler, builtin.PRIV.PRIV_JUDGE);
|
||||
ctx.Route('judge_submission_download', '/judge/code', SubmissionDataDownloadHandler, builtin.PRIV.PRIV_JUDGE);
|
||||
ctx.Connection('judge_conn', '/judge/conn', JudgeConnectionHandler, builtin.PRIV.PRIV_JUDGE);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ export interface KoaContext extends Koa.Context {
|
||||
request: Koa.Request & { body: any, files: Files };
|
||||
session: Record<string, any>;
|
||||
render: (name: string, args: any) => Promise<void>;
|
||||
renderHTML: (name: string, args: any) => Promise<string>;
|
||||
renderHTML: (name: string, args: any) => string | Promise<string>;
|
||||
getUrl: (name: string, args: any) => string;
|
||||
translate: (key: string) => string;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user