perf: verify binary hash right after download

This commit is contained in:
NamesMT 2025-04-30 16:56:48 +00:00
parent bc60b426b5
commit 765764790a

View file

@ -15,7 +15,7 @@ import { getUserLocale } from "./utils"
import { GlobalFileNames } from "src/shared/globalFileNames"
import { TerminalRegistry } from "src/integrations/terminal/TerminalRegistry"
import { assertsMpContext, createHookable, MarketplaceContext, registerMarketplaceHooks } from "roo-rocket"
import { unpackFromUint8 } from "config-rocket/cli"
import { assertsBinarySha256, unpackFromUint8 } from "config-rocket/cli"
import { uint8IsConfigPackWithParameters } from "config-rocket/cli"
/**
@ -601,6 +601,7 @@ export class MarketplaceManager {
assertsMpContext(mpContext)
const binaryUint8 = await fetchBinary(item.binaryUrl)
await assertsBinarySha256(binaryUint8, item.binaryHash)
// Install via CLI if binary is a configurable pack.
// TODO: think of a way to send the binary to the npx process
@ -617,7 +618,7 @@ export class MarketplaceManager {
)
terminalClass.terminal.show()
await terminalClass.runCommand(
`npx --yes roo-rocket@latest --mp="${JSON.stringify(mpContext).replaceAll(/"/g, '\\"')}" --cwd="${cwd}" --sha256="${item.binaryHash}" --url="${item.binaryUrl}"`,
`npx --yes roo-rocket@latest --mp="${JSON.stringify(mpContext).replaceAll(/"/g, '\\"')}" --cwd="${cwd}" --url="${item.binaryUrl}"`,
{
onLine: (line) => {
pResult.push(line)
@ -651,7 +652,6 @@ export class MarketplaceManager {
await unpackFromUint8(binaryUint8, {
hookable: customHookable,
nonAssemblyBehavior: true,
sha256: item.binaryHash,
cwd,
})
vscode.window.showInformationMessage(`"${item.name}" installed successfully`)