fix(update): fall back to GitHub releases when Gitea mirror has empty assets
This commit is contained in:
1 parent
cf5d12b0a5
commit
51502fada5
2 files changed
+12
-4
No files matched your search
@@ -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