mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core: fix error when problem title is not actually string (#704)
This commit is contained in:
1 parent
1fed4bbbb2
commit
16e0707e09
1 file changed
+2
@@ -467,6 +467,7 @@ export class ProblemModel {
|
||||
try {
|
||||
const problems = await fs.readdir(tmpdir, { withFileTypes: true });
|
||||
for (const p of problems) {
|
||||
if (process.env.HYDRO_CLI) logger.info(`Importing problem ${p.name}`);
|
||||
const i = p.name;
|
||||
if (!p.isDirectory()) continue;
|
||||
const files = await fs.readdir(path.join(tmpdir, i));
|
||||
@@ -491,6 +492,7 @@ export class ProblemModel {
|
||||
}
|
||||
const overrideContent = findOverrideContent(path.join(tmpdir, i));
|
||||
if (pdoc.difficulty && !Number.isSafeInteger(pdoc.difficulty)) delete pdoc.difficulty;
|
||||
if (typeof pdoc.title !== 'string') throw new ValidationError('title', null, 'Invalid title');
|
||||
const docId = await ProblemModel.add(
|
||||
domainId, pid, pdoc.title.trim(), overrideContent || pdoc.content || 'No content',
|
||||
operator || pdoc.owner, pdoc.tag || [], { hidden: pdoc.hidden, difficulty: pdoc.difficulty },
|
||||
|
||||
Reference in new issue
Block a user