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
+6 -6

No files matched your search

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