From 29faa16942dbdb49901050c081476f5eac196875 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 11 Jul 2023 20:29:46 +0800 Subject: [PATCH] core: bug fix --- packages/hydrooj/src/handler/problem.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 352cca9d..417561d4 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -973,7 +973,7 @@ export class ProblemCreateHandler extends Handler { ) { if (typeof pid !== 'string') pid = `P${pid}`; if (pid && await problem.get(domainId, pid)) throw new ProblemAlreadyExistError(pid); - const docId = await problem.add(domainId, pid, title, content, this.user._id, tag ?? [], hidden); + const docId = await problem.add(domainId, pid, title, content, this.user._id, tag ?? [], { hidden, difficulty }); const files = new Set(Array.from(content.matchAll(/file:\/\/([a-zA-Z0-9_-]+\.[a-zA-Z0-9]+)/g)).map((i) => i[1])); const tasks = []; for (const file of files) { @@ -986,7 +986,6 @@ export class ProblemCreateHandler extends Handler { } } await Promise.all(tasks); - if (difficulty) await problem.edit(domainId, docId, { difficulty }); this.response.body = { pid: pid || docId }; this.response.redirect = this.url('problem_files', { pid: pid || docId }); }