MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / closeFile

Function closeFile

packages/cli/src/cloud/download.ts:137–151  ·  view source on GitHub ↗
(file: NodeJS.WritableStream)

Source from the content-addressed store, hash-verified

135}
136
137function closeFile(file: NodeJS.WritableStream): Promise<void> {
138 return new Promise<void>((resolve) => {
139 // Best-effort cleanup: any underlying failure has already been
140 // surfaced as the original throw from the for-await loop. We
141 // listen for `error` so a failing close (bad fd, late ENOSPC on
142 // flush) doesn't leak an unhandled 'error' onto the stream, and
143 // resolve either way so the finally block proceeds to unlinkSync.
144 const done = (): void => {
145 file.off("error", done);
146 resolve();
147 };
148 file.once("error", done);
149 file.end(() => done());
150 });
151}

Callers 1

downloadToFileFunction · 0.85

Calls 2

doneFunction · 0.85
onceMethod · 0.80

Tested by

no test coverage detected