Merge pull request #43 from yunyingk/fix/update-asset-fallback

fix(update): fall back to GitHub releases when Gitea mirror has empty assets
This commit is contained in:
yunyingk authored and GitHub committed 2026-09-05 22:21:03 +08:00
commit eaa2b9391f
2 files changed
+12 -4

No files matched your search

+1 -2
View File
@@ -4,8 +4,7 @@
"module": "src/server.ts",
"type": "module",
"bin": {
"hose-use": "src/cli.ts",
"hose": "src/cli.ts"
"hose-use": "src/cli.ts"
},
"scripts": {
"cli": "bun run src/cli.ts",
+11 -2
View File
@@ -469,6 +469,8 @@ export async function fetchGitHubReleases(repo: string, limit = 20): Promise<Git
`https://api.github.com/repos/${repo}/releases?per_page=${limit}`,
];
let fallbackList: GitHubRelease[] = [];
for (const url of urls) {
try {
const res = await fetch(url, { headers, signal: AbortSignal.timeout(5000) });
@@ -506,13 +508,20 @@ export async function fetchGitHubReleases(repo: string, limit = 20): Promise<Git
assets,
});
}
if (list.length > 0) return list;
if (list.length > 0) {
if (list.some((r) => r.assets.length > 0)) {
return list;
}
if (fallbackList.length === 0) {
fallbackList = list;
}
}
} catch {
// try next source
}
}
return [];
return fallbackList;
}
export async function fetchGitHubRelease(