From 62613937cfdc9755cd6adde1cf7c85180d77271a Mon Sep 17 00:00:00 2001 From: undefined Date: Thu, 1 Aug 2024 23:28:42 +0800 Subject: [PATCH] vjudge: fix #848 --- packages/vjudge/src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vjudge/src/index.ts b/packages/vjudge/src/index.ts index 6a62598c8..90e92bbb3 100644 --- a/packages/vjudge/src/index.ts +++ b/packages/vjudge/src/index.ts @@ -84,13 +84,14 @@ class AccountService { } if (id.search('\\\\#') !== -1) continue; const [pid, metastr = '{}'] = id.split('#'); + const normalizedPid = pid.replace(/[_-]/g, ''); const meta = JSON.parse(metastr); - if (await ProblemModel.get(domainId, pid) || syncing[`${domainId}/${pid}`]) continue; + if (await ProblemModel.get(domainId, normalizedPid) || syncing[`${domainId}/${pid}`]) continue; syncing[`${domainId}/${pid}`] = true; try { const res = await this.api.getProblem(pid, meta); if (!res) continue; - const docId = await ProblemModel.add(domainId, pid, res.title, res.content, 1, res.tag); + const docId = await ProblemModel.add(domainId, normalizedPid, res.title, res.content, 1, res.tag); if (res.difficulty) await ProblemModel.edit(domainId, docId, { difficulty: res.difficulty }); for (const key in res.files) { await ProblemModel.addAdditionalFile(domainId, docId, key, res.files[key]);