From dfe60b5890100763a351212ae791c469beb1b1ed Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 28 Aug 2021 05:42:55 +0800 Subject: [PATCH] vjudge: prevent race --- packages/vjudge/package.json | 2 +- packages/vjudge/src/model.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index 35421a1b9..f6628363b 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/vjudge", - "version": "1.2.2", + "version": "1.2.3", "description": "Submit problems to remote oj", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/vjudge/src/model.ts b/packages/vjudge/src/model.ts index a729db175..5ef2e886c 100644 --- a/packages/vjudge/src/model.ts +++ b/packages/vjudge/src/model.ts @@ -42,7 +42,7 @@ class Service { while (pids.length) { logger.info(`${domainId}: Syncing page ${page}`); for (const pid of pids) { - if (syncing[`${domainId}/${pid}`] || await ProblemModel.get(domainId, pid)) continue; + if (await ProblemModel.get(domainId, pid) || syncing[`${domainId}/${pid}`]) continue; syncing[`${domainId}/${pid}`] = true; try { const res = await this.api.getProblem(pid);