MCPcopy Index your code
hub / github.com/codeaashu/claude-code / #drainAllChunks

Method #drainAllChunks

src/utils/task/diskOutput.ts:141–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139 }
140
141 async #drainAllChunks(): Promise<void> {
142 while (true) {
143 try {
144 if (!this.#fileHandle) {
145 await ensureOutputDir()
146 this.#fileHandle = await open(
147 this.#path,
148 process.platform === 'win32'
149 ? 'a'
150 : fsConstants.O_WRONLY |
151 fsConstants.O_APPEND |
152 fsConstants.O_CREAT |
153 O_NOFOLLOW,
154 )
155 }
156 while (true) {
157 await this.#writeAllChunks()
158 if (this.#queue.length === 0) {
159 break
160 }
161 }
162 } finally {
163 if (this.#fileHandle) {
164 const fileHandle = this.#fileHandle
165 this.#fileHandle = null
166 await fileHandle.close()
167 }
168 }
169 // you could have another .append() while we're waiting for the file to close, so we check the queue again before fully exiting
170 if (this.#queue.length) {
171 continue
172 }
173
174 break
175 }
176 }
177
178 #writeAllChunks(): Promise<void> {
179 // This code is extremely precise.

Callers 1

#drainMethod · 0.95

Calls 4

#writeAllChunksMethod · 0.95
ensureOutputDirFunction · 0.85
openFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected