core: import: auto pid

pull/323/head
undefined 3 years ago
parent be7f28e19b
commit 32651a283a

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "3.10.2",
"version": "3.10.3",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",

@ -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,

Loading…
Cancel
Save