142
* host should use `ensureFoundryLocalRuntime`, which gates and de-dupes.
143
*/
144
>
export async function provisionRuntime(overrideDir: string, platformKey: string, urlTemplate: string, version: string, token: CancellationToken): Promise<void> {
foundryLocalRuntime.ts
145
>
const addonPath = foundryAddonPath(overrideDir, platformKey);
146
>
const coreDir = foundryCoreDir(overrideDir, platformKey);
147
>
148
>
// The cache is shared by the utility processes of every open VS Code window,
149
>
// so provision into a process-unique staging dir and atomically promote each
150
>
// payload directory into place. Two concurrent first-use downloads therefore
151
>
// never write to the same final path; whichever process wins the rename is
152
>
// the published copy and the loser accepts it as success.
153
>
const url = format2(urlTemplate, { target: platformKey });
154
>
const staging = join(overrideDir, `.staging-${process.pid}-${randomSuffix()}`);
155
>
const stagingAddon = join(staging, 'prebuilds', platformKey, 'foundry_local_napi.node');
156
>
const stagingCore = join(staging, 'foundry-local-core', platformKey);
157
>
try {
158
>
await downloadAndExtractTarball(url, staging, token);
159
throwIfCancelled(token);
160
162
throw new Error(`Foundry Local native runtime download from ${url} completed but expected files are missing.`);
163
}