core: fix warnings

This commit is contained in:
undefined committed 2022-10-06 02:58:24 +08:00
1 parent 2daa7e2034
commit a2bbb7a0e3
6 files changed
+10 -8

No files matched your search

-1
View File
@@ -7,7 +7,6 @@ import fs from 'fs-extra';
import { Context } from '../context';
import { Logger } from '../logger';
import db from '../service/db';
import { sleep } from '../utils';
import {
addon, builtinModel, handler, lib, locale, model,
script, service, setting, template,
+5 -3
View File
@@ -50,13 +50,15 @@ class ProblemImportHydroHandler extends Handler {
});
});
try {
const problems = await fs.readdir(tmpdir);
for (const i of problems) {
const problems = await fs.readdir(tmpdir, { withFileTypes: true });
for (const { name: i, isDirectory } of problems) {
if (!isDirectory()) continue;
const files = await fs.readdir(path.join(tmpdir, i));
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;
let pid = pdoc?.pid;
if (!pdoc) continue;
let pid = pdoc.pid;
if (pid) {
const current = await problem.get(domainId, pid);
if (current) pid = undefined;