Skip to content

Commit 68298d2

Browse files
authored
Merge pull request #138 from Cooper-X-Oak/codex/auto-update-download-acceleration
fix(tauri): 加速自动更新下载
2 parents 1247780 + e34b3fe commit 68298d2

5 files changed

Lines changed: 82 additions & 3 deletions

File tree

.github/workflows/release-tauri.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ jobs:
222222
OPENLESS_UPDATE_TARGET: ${{ matrix.updater-target }}
223223
OPENLESS_UPDATE_ARCH: ${{ matrix.updater-arch }}
224224
OPENLESS_UPDATE_REPO: appergb/openless
225+
OPENLESS_UPDATE_MIRROR_BASE_URL: https://fastgit.cc/https://github.com
225226
run: node scripts/write-updater-manifest.mjs
226227

227228
# ── 收集产物 ──
@@ -266,6 +267,7 @@ jobs:
266267
openless-all/app/src-tauri/target/release/bundle/macos/*.app.tar.gz
267268
openless-all/app/src-tauri/target/release/bundle/macos/*.app.tar.gz.sig
268269
openless-all/app/src-tauri/target/release/bundle/latest-darwin-aarch64.json
270+
openless-all/app/src-tauri/target/release/bundle/latest-darwin-aarch64-mirror.json
269271
if-no-files-found: error
270272

271273
- name: Upload Windows artifacts
@@ -287,6 +289,7 @@ jobs:
287289
openless-all/app/src-tauri/target/release/bundle/nsis/*.exe.sig
288290
openless-all/app/src-tauri/target/release/bundle/msi/*.msi.sig
289291
openless-all/app/src-tauri/target/release/bundle/latest-windows-x86_64.json
292+
openless-all/app/src-tauri/target/release/bundle/latest-windows-x86_64-mirror.json
290293
if-no-files-found: error
291294

292295
- name: Upload Linux artifacts
@@ -308,6 +311,7 @@ jobs:
308311
path: |
309312
openless-all/app/src-tauri/target/release/bundle/appimage/*.AppImage.sig
310313
openless-all/app/src-tauri/target/release/bundle/latest-linux-x86_64.json
314+
openless-all/app/src-tauri/target/release/bundle/latest-linux-x86_64-mirror.json
311315
if-no-files-found: error
312316

313317
# ── tag 推送时,同步上传到 GitHub Release ──
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Auto Update Download Acceleration
2+
3+
## Problem
4+
5+
OpenLess used a single Tauri updater endpoint on GitHub Releases:
6+
7+
```text
8+
https://github.com/appergb/openless/releases/latest/download/latest-{{target}}-{{arch}}.json
9+
```
10+
11+
The manifest also pointed installer downloads back to GitHub Releases. On networks where GitHub release assets are slow, a small updater package can take minutes to download.
12+
13+
Desktop apps do not reliably inherit a user's shell proxy environment. Instead of making updater correctness depend on whether a proxy is visible to the app process, the updater should use a GitHub release acceleration URL directly.
14+
15+
## Runtime Behavior
16+
17+
The app does not manually probe local proxy ports. It lets the OS/process network stack do whatever it normally does, while the updater endpoint itself points at `fastgit.cc` first. This keeps the rule simple: proxy or no proxy, updater traffic should prefer the fastgit transport.
18+
19+
## Fastgit Acceleration
20+
21+
Release builds now publish two updater manifests per target:
22+
23+
```text
24+
latest-<target>-<arch>.json
25+
latest-<target>-<arch>-mirror.json
26+
```
27+
28+
The client checks the mirror manifest first, then GitHub. The mirror manifest points its installer URL at:
29+
30+
```text
31+
https://fastgit.cc/https://github.com/<repo>/releases/latest/download/<asset>
32+
```
33+
34+
The updater signature still protects the downloaded package. The mirror only changes transport; it cannot replace the signed payload without verification failing.
35+
36+
## Maintainer Notes
37+
38+
Set `OPENLESS_UPDATE_MIRROR_BASE_URL` in CI to change the mirror host. Keep it formatted as a prefix for GitHub URLs, for example:
39+
40+
```text
41+
https://fastgit.cc/https://github.com
42+
```
43+
44+
If a mirror becomes unreliable, replace that environment value and the mirror endpoint in `openless-all/app/src-tauri/tauri.conf.json`.
45+
46+
## Evidence
47+
48+
Measured from Windows on 2026-05-01. Direct GitHub release downloads were tested with local proxy disabled to reproduce the slow path. `fastgit.cc` was tested both through the normal local proxy environment and with local proxy disabled; results vary by route, so do not treat one machine's no-proxy number as a CDN SLA.
49+
50+
```text
51+
Direct GitHub installer asset, 4.78 MB, proxy disabled:
52+
run 1: timed out after 90.75s, 1.73 MB received
53+
run 2: timed out after 90.06s, 2.44 MB received
54+
55+
fastgit.cc installer asset, 4.78 MB, normal local proxy environment:
56+
with protocol prefix: 3.12s / 3.63s / 3.39s
57+
without protocol prefix: 2.92s / 2.45s / 2.87s
58+
59+
fastgit.cc target-user signal:
60+
manual browser/download usage reported completing in under 1s without enabling a proxy.
61+
```
62+
63+
This is enough to justify a `fastgit.cc` mirror path, but not enough to treat a public mirror as permanently trusted infrastructure. `fastgit.cc` explicitly documents support for GitHub release/archive acceleration and accepts GitHub links with or without the protocol prefix. Keep the mirror configurable and re-test before each release if download performance is a release blocker.

openless-all/app/scripts/write-updater-manifest.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url';
77
const target = process.env.OPENLESS_UPDATE_TARGET;
88
const arch = process.env.OPENLESS_UPDATE_ARCH;
99
const repo = process.env.OPENLESS_UPDATE_REPO || 'appergb/openless';
10+
const mirrorBaseUrl = process.env.OPENLESS_UPDATE_MIRROR_BASE_URL || 'https://fastgit.cc/https://github.com';
1011

1112
if (!target || !arch) {
1213
throw new Error('OPENLESS_UPDATE_TARGET and OPENLESS_UPDATE_ARCH are required');
@@ -52,12 +53,20 @@ if (!existsSync(signaturePath)) {
5253

5354
const assetName = basename(artifact);
5455
const manifestName = `latest-${target}-${arch}.json`;
56+
const mirrorManifestName = `latest-${target}-${arch}-mirror.json`;
57+
const githubAssetUrl = `https://github.com/${repo}/releases/latest/download/${assetName}`;
58+
const mirrorAssetUrl = `${mirrorBaseUrl.replace(/\/$/, '')}/${repo}/releases/latest/download/${assetName}`;
5559
const manifest = {
5660
version: packageJson.version,
5761
pub_date: new Date().toISOString(),
58-
url: `https://github.com/${repo}/releases/latest/download/${assetName}`,
62+
url: githubAssetUrl,
5963
signature: readFileSync(signaturePath, 'utf8').trim(),
6064
};
65+
const mirrorManifest = {
66+
...manifest,
67+
url: mirrorAssetUrl,
68+
};
6169

6270
writeFileSync(join(bundleDir, manifestName), `${JSON.stringify(manifest, null, 2)}\n`);
63-
console.log(`Wrote ${manifestName} for ${assetName}`);
71+
writeFileSync(join(bundleDir, mirrorManifestName), `${JSON.stringify(mirrorManifest, null, 2)}\n`);
72+
console.log(`Wrote ${manifestName} and ${mirrorManifestName} for ${assetName}`);

openless-all/app/src-tauri/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"updater": {
8989
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDFERUFBODAzNTY0QzMyM0YKUldRL01reFdBNmpxSGE1K0JadlpONXNWTzhJcGZCRGxjUVdIWExNNFJpeUNsSGZwazdlQThhemkK",
9090
"endpoints": [
91+
"https://fastgit.cc/https://github.com/appergb/openless/releases/latest/download/latest-{{target}}-{{arch}}-mirror.json",
9192
"https://github.com/appergb/openless/releases/latest/download/latest-{{target}}-{{arch}}.json"
9293
]
9394
}

openless-all/app/src/components/AutoUpdate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { useTranslation } from 'react-i18next';
77
import { isTauri, restartApp } from '../lib/ipc';
88
import { Btn } from '../pages/_atoms';
99

10+
const UPDATE_CHECK_TIMEOUT_MS = 15_000;
11+
1012
export type UpdateStatus =
1113
| 'idle'
1214
| 'checking'
@@ -78,7 +80,7 @@ export function useAutoUpdate(): UseAutoUpdate {
7880
return;
7981
}
8082
const { check } = await import('@tauri-apps/plugin-updater');
81-
const next = await check();
83+
const next = await check({ timeout: UPDATE_CHECK_TIMEOUT_MS });
8284
updateRef.current = next;
8385
setVersion(next?.version ?? '');
8486
setStatus(next ? 'available' : 'none');

0 commit comments

Comments
 (0)