diff --git a/packages/feature-import/src/jobs/code-repo.ts b/packages/feature-import/src/jobs/code-repo.ts index 78db8f6..7286ea1 100644 --- a/packages/feature-import/src/jobs/code-repo.ts +++ b/packages/feature-import/src/jobs/code-repo.ts @@ -27,7 +27,7 @@ function moduleNumber(m: { id: string; title: string }, index: number): number { return folderNumber(m.title) ?? index + 1; } -/** One level of single-directory wrappers ("Repo-main/Repo-main/…") is skipped. */ +/** Single-directory wrappers ("Repo-main/…") of a zip are skipped. */ async function effectiveRoot(dir: string): Promise { for (let i = 0; i < 3; i++) { const entries = (await readdir(dir, { withFileTypes: true })).filter((e) => !e.name.startsWith(".") && e.name !== "__MACOSX"); @@ -62,11 +62,10 @@ export async function importCodeRepo(d: Deps, payload: unknown, jc: JobContext): await jc.reportProgress(0.05, "Unpacking the repository zip"); const src = await openSource(path); await src.extract(src.entries.filter((e) => !e.startsWith("__MACOSX/")), join(stage, "repo"), jc.signal); - root = join(stage, "repo"); + root = await effectiveRoot(join(stage, "repo")); // GitHub-style zips wrap everything in one folder } else { root = path; // an extracted folder is only read } - root = await effectiveRoot(root); const modules: any[] = course.manifest.modules ?? []; const folders = (await readdir(root, { withFileTypes: true })).filter((e) => e.isDirectory() && !SKIP_DIRS.has(e.name) && !e.name.startsWith(".")).map((e) => e.name).sort();