core: upgrade: fix race condition

This commit is contained in:
undefined committed 2021-10-29 21:46:13 +08:00
1 parent c116d6a212
commit 23822ea2f5
2 files changed
+8 -8

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.1.18",
"version": "3.1.19",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+7 -7
View File
@@ -602,13 +602,13 @@ const scripts: UpgradeScript[] = [
).toArray();
for (const ctdoc of ctdocs) {
if (!ctdoc.journal?.filter((i) => isStringPid(i.pid)).length) continue;
const $set = {
journal: await Promise.all(ctdoc.journal.map(async (i) => {
const pdoc = await getProblem(doc.domainId, i.pid);
if (pdoc) i.pid = pdoc.docId;
return i;
})),
};
const journal = [];
for (const i of ctdoc.journal) {
const pdoc = await getProblem(doc.domainId, i.pid);
if (pdoc) i.pid = pdoc.docId;
journal.push(i);
}
const $set = { journal };
await document.setStatus(doc.domainId, doc.docType, doc.docId, ctdoc.uid, $set);
}
await contest.edit(doc.domainId, doc.docId, { pids });