mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: model.problem.add/del AdditionalFile
This commit is contained in:
1 parent
25e7e00518
commit
9e92891fb2
5 files changed
+36
-45
No files matched your search
@@ -158,6 +158,18 @@ export async function delTestdata(domainId: string, pid: number, name: string |
|
||||
await pull(domainId, pid, 'data', names);
|
||||
}
|
||||
|
||||
export async function addAdditionalFile(domainId: string, pid: number, name: string, f: Readable | Buffer | string) {
|
||||
await storage.put(`problem/${domainId}/${pid}/additional_file/${name}`, f);
|
||||
const meta = await storage.getMeta(`problem/${domainId}/${pid}/additional_file/${name}`);
|
||||
return await push(domainId, pid, 'additional_file', meta);
|
||||
}
|
||||
|
||||
export async function delAdditionalFile(domainId: string, pid: number, name: string | string[]) {
|
||||
const names = name instanceof Array ? name : [name];
|
||||
await storage.del(names.map((t) => `problem/${domainId}/${pid}/additional_file/${t}`));
|
||||
await pull(domainId, pid, 'additional_file', names);
|
||||
}
|
||||
|
||||
export async function random(domainId: string, query: FilterQuery<Pdoc>): Promise<string | null> {
|
||||
const cursor = document.getMulti(domainId, document.TYPE_PROBLEM, query);
|
||||
const pcount = await cursor.count();
|
||||
@@ -239,6 +251,8 @@ global.Hydro.model.problem = {
|
||||
random,
|
||||
addTestdata,
|
||||
delTestdata,
|
||||
addAdditionalFile,
|
||||
delAdditionalFile,
|
||||
getMulti,
|
||||
getList,
|
||||
getListStatus,
|
||||
|
||||
Reference in new issue
Block a user