Files
Willie 887461b36a perf(upgrade): download release assets over parallel ranges (#381)
* perf(upgrade): download release assets over parallel ranges

release-assets.githubusercontent.com throttles each connection on some
networks. The 9.6 MB darwin_arm64 archive took 122-171 s over one
connection but 25 s as 8 ranges, each on its own connection, with an
identical checksum. `skillshare upgrade` and the first `skillshare ui`
of a new version both waited minutes on that download.

DownloadToFile probes with `Range: bytes=0-0`; a 206 answer splits the
file into ranges fetched in parallel from the redirected URL, and a 200
answer streams the single response as before, so servers without range
support cost no extra request. Size limits and checksum verification are
unchanged.

The UI asset download is about 2 MB now, so the docs no longer say 1 MB.

* fix(upgrade): keep the caller's transport for parallel ranges

Each range built its client from http.DefaultTransport, so a caller's
custom transport (private CA, authenticated proxy, custom dialer) only
applied to the probe. The ranges then failed or bypassed the caller's
network setup even though the probe succeeded. Each range now copies the
caller's client with a clone of its *http.Transport, which keeps those
settings and still gives the range its own connection. A transport that
cannot be cloned is shared as is.
2026-10-04 14:03:46 +08:00
..