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:
2 files changed
+12
-4
No files matched your search
+1
-2
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user