mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: import: auto pid
This commit is contained in:
1 parent
be7f28e19b
commit
32651a283a
2 files changed
+6
-3
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user