Release v0.9.4: Optimize update fail-safe fallback routing and enforce global skill sync
This commit is contained in:
1 parent
191e67957d
commit
2c1de28a16
9 files changed
+93
-55
No files matched your search
+36
-17
@@ -379,6 +379,8 @@ async function fetchGitHubRelease(repo: string, targetVersion?: string): Promise
|
||||
`https://api.github.com/repos/${repo}/releases/latest`
|
||||
];
|
||||
|
||||
let fallbackRelease: GitHubRelease | undefined;
|
||||
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const res = await fetch(url, { headers, signal: AbortSignal.timeout(5000) });
|
||||
@@ -403,7 +405,7 @@ async function fetchGitHubRelease(repo: string, targetVersion?: string): Promise
|
||||
size: item.size ?? 0
|
||||
}));
|
||||
|
||||
return {
|
||||
const candidateRelease: GitHubRelease = {
|
||||
version,
|
||||
tagName,
|
||||
name: json.name ?? tagName,
|
||||
@@ -413,12 +415,22 @@ async function fetchGitHubRelease(repo: string, targetVersion?: string): Promise
|
||||
htmlUrl: json.html_url ?? "",
|
||||
assets
|
||||
};
|
||||
|
||||
// If this source already has uploaded assets, return it immediately.
|
||||
if (assets.length > 0) {
|
||||
return candidateRelease;
|
||||
}
|
||||
|
||||
// Otherwise keep as fallback (in case all sources have no assets)
|
||||
if (!fallbackRelease) {
|
||||
fallbackRelease = candidateRelease;
|
||||
}
|
||||
} catch {
|
||||
// try next source
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return fallbackRelease;
|
||||
}
|
||||
|
||||
function matchAssetForPlatform(
|
||||
@@ -470,25 +482,32 @@ function logProgress(msg: string) {
|
||||
|
||||
async function downloadFile(url: string, destPath: string, tagName?: string, assetName?: string) {
|
||||
const candidates: string[] = [];
|
||||
const tag = tagName ? (tagName.startsWith("v") ? tagName : `v${tagName}`) : undefined;
|
||||
const fileName = assetName || url.split("/").pop() || "";
|
||||
|
||||
// 1. High-speed Gitea direct mirror first
|
||||
if (tagName && assetName) {
|
||||
const tag = tagName.startsWith("v") ? tagName : `v${tagName}`;
|
||||
candidates.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${tag}/${assetName}`);
|
||||
if (tag && fileName) {
|
||||
candidates.push(`https://git.ying-qing.cn/gitea/seal-home/releases/download/${tag}/${fileName}`);
|
||||
}
|
||||
if (url.startsWith("https://git.ying-qing.cn")) {
|
||||
candidates.push(url);
|
||||
}
|
||||
|
||||
// 2. Direct url if it's not already Gitea
|
||||
if (url.startsWith("https://git.ying-qing.cn")) {
|
||||
candidates.unshift(url);
|
||||
// 2. Fast GitHub CDN proxies and direct GitHub fallback
|
||||
if (tag && fileName) {
|
||||
const ghDirectUrl = `https://github.com/${DEFAULT_GITHUB_REPO}/releases/download/${tag}/${fileName}`;
|
||||
candidates.push(`https://ghfast.top/${ghDirectUrl}`);
|
||||
candidates.push(`https://ghproxy.net/${ghDirectUrl}`);
|
||||
candidates.push(`https://gh.ddlc.top/${ghDirectUrl}`);
|
||||
candidates.push(`https://mirror.ghproxy.com/${ghDirectUrl}`);
|
||||
candidates.push(ghDirectUrl);
|
||||
} else if (url.includes("github.com")) {
|
||||
candidates.push(`https://ghfast.top/${url}`);
|
||||
candidates.push(`https://ghproxy.net/${url}`);
|
||||
candidates.push(`https://gh.ddlc.top/${url}`);
|
||||
candidates.push(`https://mirror.ghproxy.com/${url}`);
|
||||
candidates.push(url);
|
||||
} else {
|
||||
// 3. Fast GitHub CDN proxies
|
||||
if (url.includes("github.com")) {
|
||||
candidates.push(`https://ghfast.top/${url}`);
|
||||
candidates.push(`https://ghproxy.net/${url}`);
|
||||
candidates.push(`https://gh.ddlc.top/${url}`);
|
||||
candidates.push(`https://mirror.ghproxy.com/${url}`);
|
||||
}
|
||||
// 4. Direct GitHub fallback
|
||||
candidates.push(url);
|
||||
}
|
||||
|
||||
@@ -500,7 +519,7 @@ async function downloadFile(url: string, destPath: string, tagName?: string, ass
|
||||
const candidate = uniqueCandidates[i]!;
|
||||
try {
|
||||
logProgress(`==> [${i + 1}/${uniqueCandidates.length}] Downloading via: ${candidate}`);
|
||||
const res = await fetch(candidate, { signal: AbortSignal.timeout(10000) });
|
||||
const res = await fetch(candidate, { signal: AbortSignal.timeout(6000) });
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user