7 Commits
Author SHA1 Message Date
Willie fe92a50b1b fix(upgrade): preserve UI assets for the pre-upgrade version (#571)
An already-running UI server still reads lazy-loaded chunks from its versioned cache after the CLI binary is upgraded. Preserve the pre-upgrade version alongside the downloaded version so upgrade cleanup does not break page navigation.

Add a multi-version cleanup regression test and document the retention policy and accepted consecutive-upgrade limitation across all website locales.
2026-10-14 23:10:44 +08:00
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
Willie dadbbc7649 fix: close temp downloads before removing them on error (#340)
Both release downloaders removed the temp file while it was still open,
relying on the deferred Close. Windows refuses to delete an open file, so
an interrupted or oversized download could leave up to ~100 MB behind in
%TEMP%. Closing first makes the cleanup work on every platform.

Raised in review of #335; downloadToTemp in uidist had the same pattern.
2026-10-02 22:45:32 +08:00
star-nebulaandWillie 2bf7e66790 fix(upgrade): verify the release archive before replacing the binary (#335)
* refactor(version): own the release checksum helpers

The UI asset download already verifies its tarball against the release
checksums file, but the fetch, parse, and hashing helpers were private to
`internal/uidist`, so a second caller had nothing to reuse: `internal/version`
builds the checksums URL and `internal/utils` already hashes files.

Move the parser and the fetcher next to the URL they consume, keep the same
messages, and drop uidist's private SHA-256 duplicate in favour of
`utils.FileHash`. No behavior change.

* fix(upgrade): verify the release archive before replacing the binary

`skillshare upgrade --cli` streamed the release archive straight into the
extractor and renamed the result over the live executable, so an archive that
did not match the release was installed anyway. The UI asset download in the
same product has always refused on a mismatch, and the release workflow checks
every asset against checksums.txt before publishing, so the published hashes
were the one integrity signal this path did not consult.

Stage the archive to a temp file, compare its SHA-256 with the entry for the
downloaded asset name, and extract only when they agree. A mismatch, an entry
for a different file, or an unreachable checksums.txt stops the upgrade and
leaves the running binary untouched. This guards against damaged or mismatched
downloads rather than a release whose assets and checksums were replaced
together.

Tests use a local server and build the archive each platform extracts, so all
four outcomes are covered without network access. The sudo child re-enters this
same function, so elevated upgrades are covered too.

---------

Co-authored-by: Willie <egg358358@gmail.com>
2026-10-02 22:35:47 +08:00
Willie 65ac2d3eed feat(upgrade): show download progress so slow downloads don't look stuck
On a slow GitHub CDN the ~9MB release archive can take minutes, and a
bare spinner made upgrade look hung, prompting users to abort it.
Show bytes read / total for the CLI and UI asset downloads on a TTY.
2026-09-21 22:29:26 +08:00
Willie d99653025c refactor: unify CacheDir into config package and document all platform paths
Move GetCacheDir() from version package to config.CacheDir(), consistent
with BaseDir()/DataDir()/StateDir() pattern including Windows fallback.
Add XDG_CACHE_HOME and cache paths to website docs.
2026-02-16 12:58:28 +08:00
Willie 41e822d979 feat: remove go:embed, serve UI exclusively via runtime download
Replace the embedded SPA (go:embed + build tags) with runtime download
from GitHub Releases. The binary no longer bundles UI assets — they are
downloaded on first `skillshare ui` launch and cached at
~/.cache/skillshare/ui/<version>/.

- Delete embed.go / embed_dev.go; add spa_disk.go with placeholder handler
- Simplify ensureUIAvailable(): cache check before dev-mode fallback
- Pre-download UI assets in `skillshare upgrade` (best-effort)
- Remove Node stages from production and CI Dockerfiles
- Keep Node stage in sandbox for playground UI cache pre-population
- Remove ui-embed-check CI job and -tags dev build flag
- Update Makefile, mise.toml, GoReleaser, release workflow
2026-02-16 02:58:22 +08:00