core: import: auto pid

This commit is contained in:
undefined committed 2022-03-21 08:38:25 +08:00
1 parent be7f28e19b
commit 32651a283a
2 files changed
+6 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.10.2",
"version": "3.10.3",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+5 -2
View File
@@ -51,8 +51,11 @@ class ProblemImportHydroHandler extends Handler {
if (!files.includes('problem.yaml')) continue;
const content = fs.readFileSync(path.join(tmpdir, i, 'problem.yaml'), 'utf-8');
const pdoc: ProblemDoc = yaml.load(content) as any;
const current = await problem.get(domainId, pdoc.pid);
const pid = current ? undefined : pdoc.pid;
let pid = pdoc?.pid;
if (pid) {
const current = await problem.get(domainId, pid);
if (current) pid = undefined;
}
const overrideContent = findOverrideContent(path.join(tmpdir, i));
const docId = await problem.add(
domainId, pid, pdoc.title, overrideContent || pdoc.content,