MCPcopy Index your code
hub / github.com/coder/mux / writeReadableStreamToLocalFile

Function writeReadableStreamToLocalFile

src/node/services/gitPatchArtifactService.ts:55–80  ·  view source on GitHub ↗
(
  stream: ReadableStream<Uint8Array>,
  filePath: string
)

Source from the content-addressed store, hash-verified

53}
54
55async function writeReadableStreamToLocalFile(
56 stream: ReadableStream<Uint8Array>,
57 filePath: string
58): Promise<void> {
59 assert(filePath.length > 0, "writeReadableStreamToLocalFile: filePath must be non-empty");
60
61 await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
62
63 const fileHandle = await fsPromises.open(filePath, "w");
64 try {
65 const reader = stream.getReader();
66 try {
67 while (true) {
68 const { done, value } = await reader.read();
69 if (done) break;
70 if (value) {
71 await fileHandle.write(value);
72 }
73 }
74 } finally {
75 reader.releaseLock();
76 }
77 } finally {
78 await fileHandle.close();
79 }
80}
81
82function getPrimaryProjectName(projectPath: string, projects?: ProjectRef[]): string {
83 const matchingProjectName = projects

Callers 1

generateMethod · 0.85

Calls 5

writeMethod · 0.65
closeMethod · 0.65
assertFunction · 0.50
openMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected