mirror of
https://github.com/moeru-ai/airi.git
synced 2026-08-14 08:52:42 +00:00
refactor(stage-tamagotchi): use ofetch for Steam SDK download
This commit is contained in:
@@ -112,6 +112,7 @@
|
||||
"mediabunny": "catalog:",
|
||||
"node-vibrant": "catalog:",
|
||||
"nprogress": "catalog:",
|
||||
"ofetch": "catalog:",
|
||||
"onnxruntime-web": "catalog:",
|
||||
"pinia": "catalog:",
|
||||
"popmotion": "catalog:",
|
||||
|
||||
@@ -25,6 +25,7 @@ import { dirname, join, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { errorMessageFrom } from '@moeru/std'
|
||||
import { ofetch } from 'ofetch'
|
||||
|
||||
// NOTICE:
|
||||
// Keep in sync with apps/stage-tamagotchi/steam_appid.txt. Inlined here so the
|
||||
@@ -53,12 +54,19 @@ function mirrorBaseUrl(): string {
|
||||
}
|
||||
|
||||
async function downloadFile(url: string, dest: string): Promise<void> {
|
||||
const response = await fetch(url)
|
||||
const response = await ofetch.raw(url, {
|
||||
responseType: 'arrayBuffer',
|
||||
ignoreResponseError: true,
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download ${url}: HTTP ${response.status}`)
|
||||
}
|
||||
|
||||
const bytes = Buffer.from(await response.arrayBuffer())
|
||||
const data = response._data
|
||||
if (!(data instanceof ArrayBuffer))
|
||||
throw new Error(`Unexpected response type from ${url}`)
|
||||
|
||||
const bytes = Buffer.from(data)
|
||||
if (bytes.length === 0) {
|
||||
throw new Error(`Downloaded empty file from ${url}`)
|
||||
}
|
||||
|
||||
Generated
+3
@@ -2026,6 +2026,9 @@ importers:
|
||||
nprogress:
|
||||
specifier: 'catalog:'
|
||||
version: 0.2.0
|
||||
ofetch:
|
||||
specifier: 'catalog:'
|
||||
version: 1.5.1
|
||||
onnxruntime-web:
|
||||
specifier: npm:onnxruntime-web@^1.24.3
|
||||
version: 1.24.3
|
||||
|
||||
Reference in New Issue
Block a user