Skip to content

Commit ab6f258

Browse files
Merge branch 'hydro-dev:master' into master
2 parents 7be3af4 + fdb4f18 commit ab6f258

File tree

15 files changed

+57
-88
lines changed

15 files changed

+57
-88
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ Hydro 用户群:1085853538
111111
<details>
112112
<summary><h2>更新日志(点击展开)</h2></summary>
113113

114+
## Hydro 4.18.2 / UI 4.56.2
115+
116+
- core: 修复提交答案题压缩包提交 (#917)
117+
- ui: 优化 domain_user 页面性能
118+
- core: 优化评测任务调度
119+
- ui: 下载文件失败时自动重试
120+
- core: Consumer: 从错误中自动恢复
121+
114122
## Hydro 4.18.0 / UI 4.56.0
115123

116124
- core&ui: ScoreboardView API

framework/eslint-config/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"license": "MIT",
55
"main": "react.yaml",
66
"dependencies": {
7-
"@stylistic/eslint-plugin": "^2.12.0",
8-
"@typescript-eslint/eslint-plugin": "^8.17.0",
9-
"@typescript-eslint/parser": "^8.17.0",
7+
"@stylistic/eslint-plugin": "^2.12.1",
8+
"@typescript-eslint/eslint-plugin": "^8.18.0",
9+
"@typescript-eslint/parser": "^8.18.0",
1010
"eslint-config-airbnb": "^19.0.4",
1111
"eslint-plugin-github": "^5.1.4",
1212
"eslint-plugin-import": "2.31.0",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"esbuild": "0.24.0",
4848
"eslint": "^8.57.1",
4949
"eslint-import-resolver-typescript": "^3.7.0",
50-
"eslint-import-resolver-webpack": "^0.13.9",
50+
"eslint-import-resolver-webpack": "^0.13.10",
5151
"fs-extra": "^11.2.0",
5252
"globby": "^14.0.2",
5353
"inspectpack": "^4.7.1",

packages/elastic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"author": "undefined <[email protected]>",
77
"license": "AGPL-3.0-or-later",
88
"dependencies": {
9-
"@elastic/elasticsearch": "^8.16.2"
9+
"@elastic/elasticsearch": "^8.17.0"
1010
}
1111
}

packages/hydrooj/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hydrooj",
3-
"version": "4.18.1",
3+
"version": "4.18.2",
44
"bin": "bin/hydrooj.js",
55
"main": "src/plugin-api",
66
"module": "src/plugin-api",
@@ -12,11 +12,11 @@
1212
},
1313
"preferUnplugged": true,
1414
"dependencies": {
15-
"@aws-sdk/client-s3": "3.705.0",
16-
"@aws-sdk/lib-storage": "3.705.0",
17-
"@aws-sdk/s3-presigned-post": "3.705.0",
18-
"@aws-sdk/s3-request-presigner": "3.705.0",
19-
"@graphql-tools/schema": "^10.0.11",
15+
"@aws-sdk/client-s3": "3.712.0",
16+
"@aws-sdk/lib-storage": "3.712.0",
17+
"@aws-sdk/s3-presigned-post": "3.712.0",
18+
"@aws-sdk/s3-request-presigner": "3.712.0",
19+
"@graphql-tools/schema": "^10.0.12",
2020
"@hydrooj/framework": "workspace:^",
2121
"@hydrooj/utils": "workspace:^",
2222
"@simplewebauthn/server": "9.0.3",

packages/hydrooj/src/handler/home.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { generateRegistrationOptions, verifyRegistrationResponse } from '@simple
33
import yaml from 'js-yaml';
44
import { pick } from 'lodash';
55
import { Binary, ObjectId } from 'mongodb';
6-
import Parser from 'ua-parser-js';
6+
import { UAParser } from 'ua-parser-js';
77
import { Context } from '../context';
88
import {
99
AuthOperationError, BlacklistedError, DomainAlreadyExistsError, InvalidTokenError,
@@ -186,10 +186,7 @@ class HomeSecurityHandler extends Handler {
186186
session.isCurrent = session._id === this.session._id;
187187
session._id = md5(session._id);
188188
const ua = session.updateUa || session.createUa;
189-
if (ua) {
190-
const parser = new Parser(ua);
191-
session.updateUaInfo = parser.getResult();
192-
}
189+
if (ua) session.updateUaInfo = UAParser(ua);
193190
session.updateGeoip = this.ctx.geoip?.lookup?.(
194191
session.updateIp || session.createIp,
195192
this.translate('geoip_locale'),
@@ -253,7 +250,7 @@ class HomeSecurityHandler extends Handler {
253250
}
254251

255252
@param('tokenDigest', Types.String)
256-
async postDeleteToken(domainId: string, tokenDigest: string) {
253+
async postDeleteToken({ }, tokenDigest: string) {
257254
const sessions = await token.getSessionListByUid(this.user._id);
258255
for (const session of sessions) {
259256
if (tokenDigest === md5(session._id)) {
@@ -273,7 +270,7 @@ class HomeSecurityHandler extends Handler {
273270
@requireSudo
274271
@param('code', Types.String)
275272
@param('secret', Types.String)
276-
async postEnableTfa(domainId: string, code: string, secret: string) {
273+
async postEnableTfa({ }, code: string, secret: string) {
277274
if (this.user._tfa) throw new AuthOperationError('2FA', 'enabled');
278275
if (!verifyTFA(secret, code)) throw new InvalidTokenError('2FA');
279276
await user.setById(this.user._id, { tfa: secret });
@@ -287,7 +284,7 @@ class HomeSecurityHandler extends Handler {
287284

288285
@requireSudo
289286
@param('type', Types.Range(['cross-platform', 'platform']))
290-
async postRegister(domainId: string, type: 'cross-platform' | 'platform') {
287+
async postRegister({ }, type: 'cross-platform' | 'platform') {
291288
const options = await generateRegistrationOptions({
292289
rpName: system.get('server.name'),
293290
rpID: this.getAuthnHost(),
@@ -309,7 +306,7 @@ class HomeSecurityHandler extends Handler {
309306

310307
@requireSudo
311308
@param('name', Types.String)
312-
async postEnableAuthn(domainId: string, name: string) {
309+
async postEnableAuthn({ }, name: string) {
313310
if (!this.session.webauthnVerify) throw new InvalidTokenError(token.TYPE_TEXTS[token.TYPE_WEBAUTHN]);
314311
const verification = await verifyRegistrationResponse({
315312
response: this.args.result,
@@ -336,7 +333,7 @@ class HomeSecurityHandler extends Handler {
336333

337334
@requireSudo
338335
@param('id', Types.String)
339-
async postDisableAuthn(domainId: string, id: string) {
336+
async postDisableAuthn({ }, id: string) {
340337
const authenticators = this.user._authenticators?.filter((c) => Buffer.from(c.credentialID.buffer).toString('base64') !== id);
341338
if (this.user._authenticators?.length === authenticators?.length) throw new ValidationError('authenticator');
342339
await user.setById(this.user._id, { authenticators });
@@ -395,7 +392,7 @@ function set(s: Setting, key: string, value: any) {
395392

396393
class HomeSettingsHandler extends Handler {
397394
@param('category', Types.Range(['preference', 'account', 'domain']))
398-
async get(domainId: string, category: string) {
395+
async get({ }, category: string) {
399396
this.response.template = 'home_settings.html';
400397
this.response.body = {
401398
category,
@@ -432,7 +429,7 @@ class HomeSettingsHandler extends Handler {
432429

433430
class HomeAvatarHandler extends Handler {
434431
@param('avatar', Types.String, true)
435-
async post(domainId: string, input: string) {
432+
async post({ }, input: string) {
436433
if (input) {
437434
if (!validate(input)) throw new ValidationError('avatar');
438435
await user.setById(this.user._id, { avatar: input });
@@ -565,7 +562,7 @@ class HomeMessagesHandler extends Handler {
565562

566563
@param('uid', Types.Int)
567564
@param('content', Types.Content)
568-
async postSend(domainId: string, uid: number, content: string) {
565+
async postSend({ }, uid: number, content: string) {
569566
this.checkPriv(PRIV.PRIV_SEND_MESSAGE);
570567
const udoc = await user.getById('system', uid);
571568
if (!udoc) throw new UserNotFoundError(uid);
@@ -575,15 +572,15 @@ class HomeMessagesHandler extends Handler {
575572
}
576573

577574
@param('messageId', Types.ObjectId)
578-
async postDeleteMessage(domainId: string, messageId: ObjectId) {
575+
async postDeleteMessage({ }, messageId: ObjectId) {
579576
const msg = await message.get(messageId);
580577
if ([msg.from, msg.to].includes(this.user._id)) await message.del(messageId);
581578
else throw new PermissionError();
582579
this.back();
583580
}
584581

585582
@param('messageId', Types.ObjectId)
586-
async postRead(domainId: string, messageId: ObjectId) {
583+
async postRead({ }, messageId: ObjectId) {
587584
const msg = await message.get(messageId);
588585
if ([msg.from, msg.to].includes(this.user._id)) {
589586
await message.setFlag(messageId, message.FLAG_UNREAD);

packages/hydrooj/src/handler/problem.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,13 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
496496
if (!file || file.size === 0) throw new ValidationError('code');
497497
const sizeLimit = config.type === 'submit_answer' ? 128 * 1024 * 1024 : lengthLimit;
498498
if (file.size > sizeLimit) throw new ValidationError('file');
499-
const showReadFile = () => {
499+
const shouldReadFile = () => {
500500
if (config.type === 'objective') return true;
501-
if (lang === '_') return true;
501+
if (lang === '_') return false;
502502
return file.size < lengthLimit && !file.filepath.endsWith('.zip') && !setting.langs[lang].isBinary;
503503
};
504-
if (showReadFile()) {
505-
// TODO submission file shape
506-
code = await readFile(file.filepath, 'utf-8');
507-
} else {
504+
if (shouldReadFile()) code = await readFile(file.filepath, 'utf-8');
505+
else {
508506
const id = nanoid();
509507
await storage.put(`submission/${this.user._id}/${id}`, file.filepath, this.user._id);
510508
files.code = `${this.user._id}/${id}#${file.originalFilename}`;

packages/hydrooj/src/model/problem.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,12 @@ export class ProblemModel {
603603
if (options.delSource) await fs.remove(tmpdir);
604604
}
605605

606-
static async export(domainId: string) {
606+
static async export(domainId: string, pidFilter?:string) {
607607
console.log('Exporting problems...');
608608
const tmpdir = path.join(os.tmpdir(), 'hydro', `${Math.random()}.export`);
609609
await fs.mkdir(tmpdir);
610-
const pdocs = await ProblemModel.getMulti(domainId, {}, ProblemModel.PROJECTION_PUBLIC).toArray();
610+
const pdocs = await ProblemModel.getMulti(domainId, pidFilter ? { pid: pidFilter } : {}, ProblemModel.PROJECTION_PUBLIC).toArray();
611+
if (process.env.HYDRO_CLI) logger.info(`Exporting ${pdocs.length} problems`);
611612
for (const pdoc of pdocs) {
612613
if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid || (`P${pdoc.docId}`)} (${pdoc.title})`);
613614
const problemPath = path.join(tmpdir, `${pdoc.docId}`);

packages/hydrooj/src/service/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ class LocalStorageService {
275275
target = resolve(this.dir, convertPath(target));
276276
await ensureDir(dirname(target));
277277
if (typeof file === 'string') await copyFile(file, target);
278-
else if (file instanceof Buffer) await writeFile(target, file);
278+
else if (Buffer.isBuffer(file)) await writeFile(target, file);
279279
else await writeFile(target, await streamToBuffer(file));
280280
}
281281

packages/onsite-toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"version": "0.0.3",
44
"dependencies": {
55
"@react-spring/web": "^9.7.5",
6-
"react-use": "^17.5.1"
6+
"react-use": "^17.6.0"
77
}
88
}

0 commit comments

Comments
 (0)