MCPcopy
hub / github.com/claude-code-best/claude-code / downloadUrlToBufferWithFallback

Function downloadUrlToBufferWithFallback

scripts/postinstall.cjs:174–200  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

172}
173
174async function downloadUrlToBufferWithFallback(url) {
175 let firstError
176 try {
177 return await downloadUrlToBuffer(url)
178 } catch (e) {
179 firstError = e
180 }
181
182 const tmpRoot = path.join(
183 os.tmpdir(),
184 `ripgrep-dl-${process.pid}-${Date.now()}`,
185 )
186 const tmpFile = path.join(tmpRoot, 'archive')
187 mkdirSync(tmpRoot, { recursive: true })
188 try {
189 if (process.platform === 'win32' && tryPowerShellDownload(url, tmpFile)) {
190 return readFileSync(tmpFile)
191 }
192 if (tryCurlDownload(url, tmpFile)) {
193 return readFileSync(tmpFile)
194 }
195 } finally {
196 rmSync(tmpRoot, { recursive: true, force: true })
197 }
198
199 throw firstError
200}
201
202// --- Extract ---
203

Callers 1

downloadAndExtractFunction · 0.85

Calls 7

downloadUrlToBufferFunction · 0.85
mkdirSyncFunction · 0.85
tryPowerShellDownloadFunction · 0.85
tryCurlDownloadFunction · 0.85
rmSyncFunction · 0.85
nowMethod · 0.80
readFileSyncFunction · 0.50

Tested by

no test coverage detected