MCPcopy Index your code
hub / github.com/callstack/agent-device / materializeLocalSource

Function materializeLocalSource

src/platforms/install-source.ts:88–112  ·  view source on GitHub ↗
(
  source: MaterializeInstallSource,
  options?: { signal?: AbortSignal; downloadTimeoutMs?: number },
)

Source from the content-addressed store, hash-verified

86}
87
88async function materializeLocalSource(
89 source: MaterializeInstallSource,
90 options?: { signal?: AbortSignal; downloadTimeoutMs?: number },
91): Promise<MaterializeLocalSourceResult> {
92 if (source.kind === 'path') {
93 return {
94 localPath: expandSourcePath(source.path),
95 cleanup: async () => {},
96 };
97 }
98
99 const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'agent-device-source-'));
100 try {
101 const downloadedPath = await downloadToTempFile(tempDir, source.url, source.headers, options);
102 return {
103 localPath: downloadedPath,
104 cleanup: async () => {
105 await fs.rm(tempDir, { recursive: true, force: true });
106 },
107 };
108 } catch (error) {
109 await fs.rm(tempDir, { recursive: true, force: true });
110 throw error;
111 }
112}
113
114// fallow-ignore-next-line complexity
115async function downloadToTempFile(

Callers 1

Calls 2

expandSourcePathFunction · 0.85
downloadToTempFileFunction · 0.85

Tested by

no test coverage detected