mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: fix config hande
This commit is contained in:
1 parent
f4c3ca20a2
commit
a7dc00361c
4 files changed
+14
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.23.1",
|
||||
"version": "2.23.2",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Readable } from 'stream';
|
||||
import { ObjectID, FilterQuery } from 'mongodb';
|
||||
import { Dictionary, escapeRegExp, pick } from 'lodash';
|
||||
import { streamToBuffer } from '@hydrooj/utils/lib/utils';
|
||||
import { STATUS } from './builtin';
|
||||
import * as document from './document';
|
||||
import { buildProjection } from '../utils';
|
||||
@@ -248,6 +249,16 @@ export class ProblemModel {
|
||||
}
|
||||
}
|
||||
|
||||
bus.on('problem/addTestdata', async (domainId, docId, name) => {
|
||||
if (!['config.yaml', 'config.yml', 'Config.yaml', 'Config.yml'].includes(name)) return;
|
||||
const buf = await storage.get(`problem/${domainId}/${docId}/testdata/${name}`);
|
||||
await ProblemModel.edit(domainId, docId, { config: (await streamToBuffer(buf)).toString() });
|
||||
});
|
||||
bus.on('problem/delTestdata', async (domainId, docId, names) => {
|
||||
if (!names.includes('config.yaml')) return;
|
||||
await ProblemModel.edit(domainId, docId, { config: '' });
|
||||
});
|
||||
|
||||
ProblemModel.extend((docId, pid) => ({
|
||||
_id: new ObjectID(),
|
||||
domainId: 'system',
|
||||
|
||||
@@ -46,7 +46,7 @@ export default function (env = {}) {
|
||||
function fileLoader() {
|
||||
return {
|
||||
loader: 'file-loader',
|
||||
options: { name: '[path][name].[ext]?[sha1:hash:hex:10]' },
|
||||
options: { name: 'files/[name].[sha1:hash:hex:10].[ext]' },
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.6.2",
|
||||
"version": "4.6.3",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user