MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / fetchWaveFile

Function fetchWaveFile

frontend/app/store/global.ts:448–476  ·  view source on GitHub ↗
(
    zoneId: string,
    fileName: string,
    offset?: number
)

Source from the content-addressed store, hash-verified

446
447// when file is not found, returns {data: null, fileInfo: null}
448async function fetchWaveFile(
449 zoneId: string,
450 fileName: string,
451 offset?: number
452): Promise<{ data: Uint8Array; fileInfo: WaveFile }> {
453 const usp = new URLSearchParams();
454 usp.set("zoneid", zoneId);
455 usp.set("name", fileName);
456 if (offset != null) {
457 usp.set("offset", offset.toString());
458 }
459 const resp = await fetch(getWebServerEndpoint() + "/wave/file?" + usp.toString());
460 if (!resp.ok) {
461 if (resp.status === 404) {
462 return { data: null, fileInfo: null };
463 }
464 throw new Error("error getting wave file: " + resp.statusText);
465 }
466 if (resp.status == 204) {
467 return { data: null, fileInfo: null };
468 }
469 const fileInfo64 = resp.headers.get("X-ZoneFileInfo");
470 if (fileInfo64 == null) {
471 throw new Error(`missing zone file info for ${zoneId}:${fileName}`);
472 }
473 const fileInfo = JSON.parse(base64ToString(fileInfo64));
474 const data = await resp.arrayBuffer();
475 return { data: new Uint8Array(data), fileInfo };
476}
477
478function setNodeFocus(nodeId: string) {
479 const layoutModel = getLayoutModelForStaticTab();

Callers 1

Calls 4

fetchFunction · 0.90
base64ToStringFunction · 0.90
setMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected