From 006f969de6fc8e58cdf746112c611d9dd39d36a6 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 7 Mar 2021 21:34:41 +0800 Subject: [PATCH] core: fix problem edit without pid change --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 6de59e9e1..2d1b59ec9 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.20.5", + "version": "2.20.6", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index fa75169cd..0798af2f3 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -328,7 +328,7 @@ export class ProblemEditHandler extends ProblemManageHandler { try { content = JSON.parse(content); } catch { /* Ignore */ } - if (await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists'); + if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new BadRequestError('new pid exists'); const $update: Partial = { title, content, pid: newPid, hidden, tag, };