Skip to content

Commit c946b49

Browse files
committed
Add a kludge to avoid reinitializing data dir's memfs
1 parent fc2e6e8 commit c946b49

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ function collectPipeOutput(readable: Readable) {
2727
return () => (result + decoder.decode()).trimEnd()
2828
}
2929

30+
function memfsHasBeenSetup(memfs: MemoryFileSystem) {
31+
const memfsPriv = memfs as unknown as { root: { entries: Map<string, unknown> } }
32+
return memfsPriv.root.entries.has('lib')
33+
}
34+
3035
export async function activate(context: ExtensionContext): Promise<ALSWasmLoaderExports> {
3136
const coreDir = 'vscode-wasm/wasm-wasi-core'
3237
const corePkgJSONRaw = await workspace.fs.readFile(Uri.joinPath(context.extensionUri, coreDir, 'package.json'))
@@ -123,8 +128,8 @@ export async function activate(context: ExtensionContext): Promise<ALSWasmLoader
123128
[...presetMountPoints, ...options.fileSystemOptions.mountpoints] :
124129
presetMountPoints
125130

126-
// TODO: cache the setup result to be reused
127-
if (options.runSetupFirst) {
131+
// XXX: we assume that the setup can be skipped if it has been initialized by caller
132+
if (options.runSetupFirst && !memfsHasBeenSetup(memfsAgdaDataDir)) {
128133
const setupProcess = await this.wasm.createProcess('als', this.module, {
129134
env,
130135
args: ['--setup'],

0 commit comments

Comments
 (0)