diff --git a/projects/src/full.ts b/projects/src/full.ts index 08a272572..e3b35a8d6 100644 --- a/projects/src/full.ts +++ b/projects/src/full.ts @@ -72,7 +72,7 @@ export const resetTests = async (fs: FileSystem, projects?: number[]) => { }; export const createFiles = async (fs: FileSystem) => { - await reset(fs, ProjectFiles); + await reset(fs, ProjectFiles, "/", false); }; export const Assignments = { diff --git a/projects/src/reset.ts b/projects/src/reset.ts index f423de30a..6f54f996e 100644 --- a/projects/src/reset.ts +++ b/projects/src/reset.ts @@ -19,11 +19,19 @@ export async function resetBySuffix( } } -export async function reset(fs: FileSystem, tree: Tree, base?: string) { +export async function reset( + fs: FileSystem, + tree: Tree, + base?: string, + override = true, +) { + const items = (await fs.scandir(base ?? "/")).map((item) => item.name); for (const [key, value] of Object.entries(tree)) { const path = `${base ? `${base}/` : ""}${key}`; if (typeof value === "string") { - await fs.writeFile(path, value); + if (override || !items.includes(key)) { + await fs.writeFile(path, value); + } } else { await fs.mkdir(path); await reset(fs, value as Tree, path); diff --git a/web/src/shell/settings.tsx b/web/src/shell/settings.tsx index 4317e9ef6..53e924ed6 100644 --- a/web/src/shell/settings.tsx +++ b/web/src/shell/settings.tsx @@ -1,5 +1,5 @@ import { i18n } from "@lingui/core"; -import { Trans, t } from "@lingui/macro"; +import { Trans } from "@lingui/macro"; import { BaseContext } from "@nand2tetris/components/stores/base.context.js"; import { useContext, useEffect, useMemo, useState } from "react"; import { AppContext } from "../App.context"; @@ -34,12 +34,12 @@ export const Settings = () => { const upgradeFsAction = async (createFiles?: boolean) => { setUpgrading(true); - try { - await upgradeFs(localFsRoot != undefined, createFiles); - } catch (err) { - console.error("Failed to upgrade FS", { err }); - setStatus(t`Failed to load local file system.`); - } + // try { + await upgradeFs(localFsRoot != undefined, createFiles); + // } catch (err) { + // console.error("Failed to upgrade FS", { err }); + // setStatus(t`Failed to load local file system.`); + // } setUpgrading(false); };