mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix problem import
This commit is contained in:
1 file changed
+7
-3
@@ -480,7 +480,7 @@ export class ProblemModel {
|
|||||||
}
|
}
|
||||||
const files = await fs.readdir(tmpdir, { withFileTypes: true });
|
const files = await fs.readdir(tmpdir, { withFileTypes: true });
|
||||||
problems = files.filter((f) => f.isDirectory()).map((i) => i.name);
|
problems = files.filter((f) => f.isDirectory()).map((i) => i.name);
|
||||||
} finally {
|
} catch (e) {
|
||||||
if (options.delSource) await fs.remove(tmpdir);
|
if (options.delSource) await fs.remove(tmpdir);
|
||||||
}
|
}
|
||||||
for (const i of problems) {
|
for (const i of problems) {
|
||||||
@@ -504,8 +504,12 @@ export class ProblemModel {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
const getFiles = async (...type: string[]) => {
|
const getFiles = async (...type: string[]): Promise<[fs.Dirent, string][]> => {
|
||||||
if (type.length > 1) return type.flatMap((t) => getFiles(t));
|
if (type.length > 1) {
|
||||||
|
let result = [];
|
||||||
|
for (const t of type) result = result.concat(await getFiles(t));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
const [t] = type;
|
const [t] = type;
|
||||||
if (!files.find((f) => f.name === t && f.isDirectory())) return [];
|
if (!files.find((f) => f.name === t && f.isDirectory())) return [];
|
||||||
const rs = await fs.readdir(path.join(tmpdir, i, t), { withFileTypes: true });
|
const rs = await fs.readdir(path.join(tmpdir, i, t), { withFileTypes: true });
|
||||||
|
|||||||
Reference in new issue
Block a user