mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: import.syzoj: async
This commit is contained in:
1 parent
b7330b05d1
commit
e3dad8ff60
6 files changed
+29
-17
No files matched your search
+1
-1
@@ -26,7 +26,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^3.9.1",
|
||||
"@typescript-eslint/parser": "^3.9.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"eslint": "^7.14.0",
|
||||
"eslint": "^7.16.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-import-resolver-typescript": "^2.3.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.5.1",
|
||||
"axios": "^0.21.0",
|
||||
"axios": "^0.21.1",
|
||||
"bson": "^4.2.2",
|
||||
"fs-extra": "^9.0.1",
|
||||
"js-yaml": "^3.14.1",
|
||||
"lodash": "^4.17.20",
|
||||
"p-queue": "^6.6.1",
|
||||
"shell-quote": "^1.7.2",
|
||||
"systeminformation": "^4.32.0",
|
||||
"systeminformation": "^4.33.1",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.15.5",
|
||||
"version": "2.15.6",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
@@ -24,7 +24,7 @@
|
||||
"koa-static-cache": "^5.1.3",
|
||||
"lodash": "^4.17.20",
|
||||
"lru-cache": "^6.0.0",
|
||||
"minio": "7.0.17",
|
||||
"minio": "7.0.18",
|
||||
"moment-timezone": "^0.5.32",
|
||||
"mongodb": "^3.6.3",
|
||||
"nodemailer": "^6.4.17",
|
||||
@@ -32,7 +32,7 @@
|
||||
"serialize-javascript": "^5.0.1",
|
||||
"sockjs": "^0.3.20",
|
||||
"superagent": "^6.1.0",
|
||||
"systeminformation": "^4.32.0",
|
||||
"systeminformation": "^4.33.1",
|
||||
"terminal-kit": "^1.44.0",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { ContentNode } from '../interface';
|
||||
import * as problem from '../model/problem';
|
||||
import { PERM } from '../model/builtin';
|
||||
import {
|
||||
Route, Handler, Types, param, post,
|
||||
Route, Handler, Types, post,
|
||||
} from '../service/server';
|
||||
import storage from '../service/storage';
|
||||
import { isPid } from '../lib/validator';
|
||||
@@ -212,8 +212,8 @@ class ProblemImportSYZOJHandler extends Handler {
|
||||
}
|
||||
|
||||
@post('url', Types.String, true)
|
||||
@param('pid', Types.String, true, isPid)
|
||||
@param('hidden', Types.Boolean)
|
||||
@post('pid', Types.String, true, isPid)
|
||||
@post('hidden', Types.Boolean)
|
||||
@post('prefix', Types.String, true)
|
||||
@post('start', Types.UnsignedInt, true)
|
||||
@post('end', Types.UnsignedInt, true)
|
||||
@@ -226,16 +226,19 @@ class ProblemImportSYZOJHandler extends Handler {
|
||||
const base = `${prefix}${start}/`;
|
||||
assert(base.match(RE_SYZOJ), new ValidationError('prefix'));
|
||||
const [, protocol, host] = RE_SYZOJ.exec(base);
|
||||
for (let i = start; i <= end; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await this.v3(domainId, undefined, hidden, protocol, host, i, true);
|
||||
}
|
||||
(async () => {
|
||||
for (let i = start; i <= end; i++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await this.v3(domainId, undefined, hidden, protocol, host, i, true);
|
||||
logger.info('%s %d-%d-%d', prefix, start, i, end);
|
||||
}
|
||||
})().catch(logger.error);
|
||||
this.response.redirect = this.url('problem_main');
|
||||
} else {
|
||||
assert(url.match(RE_SYZOJ), new ValidationError('url'));
|
||||
if (!url.endsWith('/')) url += '/';
|
||||
const [, protocol, host, n, pid] = RE_SYZOJ.exec(url);
|
||||
if (n === 'p') {
|
||||
// SYZOJ-NG
|
||||
const docId = await this.v3(
|
||||
domainId, targetPid, hidden,
|
||||
protocol, host, pid, false,
|
||||
|
||||
@@ -5,8 +5,10 @@ import { safeDump } from 'js-yaml';
|
||||
import db from './db';
|
||||
import * as bus from './bus';
|
||||
import * as sysinfo from '../lib/sysinfo';
|
||||
import { Logger } from '../logger';
|
||||
|
||||
const coll = db.collection('status');
|
||||
const logger = new Logger('monitor');
|
||||
|
||||
function crypt(str: string) {
|
||||
const cipher = crypto.createCipheriv('des-ecb', 'hydro-oj', '');
|
||||
@@ -47,7 +49,9 @@ export async function feedback() {
|
||||
cpu: inf.cpu,
|
||||
flags: inf.flags,
|
||||
}));
|
||||
axios.post('https://feedback.undefined.moe/', { payload });
|
||||
axios.post('https://feedback.undefined.moe/', { payload }).catch(() => {
|
||||
logger.warn('Cannot connect to hydro center.');
|
||||
});
|
||||
}
|
||||
|
||||
export async function update() {
|
||||
|
||||
@@ -556,7 +556,10 @@ export class Handler {
|
||||
const templateName = this.request.query.template || this.response.template;
|
||||
if (templateName) {
|
||||
this.response.body = this.response.body || {};
|
||||
await this.render(templateName, this.response.body);
|
||||
const s = templateName.split('.');
|
||||
if (global.Hydro.ui.template[`${s[0]}.${this.domainId}.${s[1]}`]) {
|
||||
await this.render(`${s[0]}.${this.domainId}.${s[1]}`, this.response.body);
|
||||
} else await this.render(templateName, this.response.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -620,8 +623,9 @@ export class Handler {
|
||||
|
||||
async onerror(error: HydroError) {
|
||||
if (!error.msg) error.msg = () => error.message;
|
||||
if (error instanceof UserFacingError) error.stack = '';
|
||||
if (!(error instanceof NotFoundError)) {
|
||||
logger.error(error.msg(), error.params);
|
||||
logger.error(this.request.path, error.msg(), error.params);
|
||||
logger.error(error.stack);
|
||||
}
|
||||
this.response.status = error instanceof UserFacingError ? error.code : 500;
|
||||
@@ -813,6 +817,7 @@ export class ConnectionHandler {
|
||||
async message(message: any) { } // eslint-disable-line
|
||||
|
||||
onerror(err: HydroError) {
|
||||
if (err instanceof UserFacingError) err.stack = this.conn.pathname;
|
||||
if (!(err instanceof NotFoundError)) logger.error(err);
|
||||
this.send({
|
||||
error: {
|
||||
|
||||
Reference in new issue
Block a user