core: fix problem copy pid

This commit is contained in:
undefined committed 2021-10-25 16:48:50 +08:00
1 parent 0aba9f8215
commit b10c67f5cf
4 files changed
+21 -6

No files matched your search

+1 -1
View File
@@ -147,7 +147,7 @@ export class ProblemModel {
static async copy(domainId: string, _id: number, target: string, pid?: string) {
const original = await ProblemModel.get(domainId, _id);
if (!original) throw new ProblemNotFoundError(domainId, _id);
if (pid && await ProblemModel.get(target, pid)) pid = '';
if (pid && (/^[0-9]+$/.test(pid) || await ProblemModel.get(target, pid))) pid = '';
if (!pid && original.pid && !await ProblemModel.get(target, original.pid)) pid = original.pid;
const docId = await ProblemModel.add(
target, pid, original.title, original.content,