Changeset da71f9d in Klonkt for src/routes/admin-updates.js


Ignore:
Timestamp:
07/04/2026 05:47:49 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
8e7f0ec
Parents:
0a93c15
Message:

fix(updates): Android "Latest" reads the installable bundle version

The Android Updates page read the stable branch's package.json, which
runs ahead of the phone bundle during the CI window in which the bundle
is still being built - the page showed "1.3.4 available" while the
update button could only install the 1.3.3 tarball, so updating
appeared stuck on the same version.

"Latest" now reads BUILD-INFO.txt's new bundle-version line from the
release (= exactly what klonkt-update installs), falling back to the
stable branch for releases that predate the line. Parse logic verified
against the workflow's BUILD-INFO shape (with and without the line).

  • src/routes/admin-updates.js - androidLatestVersion(): BUILD-INFO first, stable-branch fallback; shared fetchWithTimeout helper
  • CHANGELOG(.nl/.de).md - Unreleased entry (3 languages)

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/admin-updates.js

    r0a93c15 rda71f9d  
    4545const IS_ANDROID = process.platform === 'android'
    4646  || (() => { try { return fs.existsSync('/data/data/com.termux/files/usr/bin'); } catch { return false; } })();
    47 // Phone tarballs are built from the stable branch → that's the phone's "latest".
    48 const ANDROID_LATEST_URL = 'https://raw.githubusercontent.com/roboburr/klonkt/stable/package.json';
     47// "Latest" for a phone = what the update button can actually INSTALL: the version
     48// of the prebuilt bundle on the release (BUILD-INFO.txt's bundle-version). Reading
     49// the stable branch instead showed a new version during the CI window in which the
     50// bundle was still being built — pressing update then reinstalled the old version.
     51const ANDROID_BUILDINFO_URL = 'https://github.com/roboburr/klonkt-android/releases/download/termux-latest/BUILD-INFO.txt';
     52const ANDROID_STABLE_URL = 'https://raw.githubusercontent.com/roboburr/klonkt/stable/package.json';
     53
     54async function fetchWithTimeout(url, ms) {
     55  const ctl = new AbortController();
     56  const t = setTimeout(() => ctl.abort(), ms);
     57  try { return await fetch(url, { signal: ctl.signal, redirect: 'follow' }); }
     58  finally { clearTimeout(t); }
     59}
    4960
    5061async function androidLatestVersion() {
    5162  try {
    52     const ctl = new AbortController();
    53     const t = setTimeout(() => ctl.abort(), 8000);
    54     const r = await fetch(ANDROID_LATEST_URL, { signal: ctl.signal });
    55     clearTimeout(t);
     63    const r = await fetchWithTimeout(ANDROID_BUILDINFO_URL, 8000);
     64    if (r.ok) {
     65      const m = (await r.text()).match(/^bundle-version:\s*(\S+)/m);
     66      if (m) return m[1];
     67    }
     68  } catch { /* fall through */ }
     69  // Older releases have no bundle-version line → fall back to the stable branch.
     70  try {
     71    const r = await fetchWithTimeout(ANDROID_STABLE_URL, 8000);
    5672    if (!r.ok) return null;
    5773    return (await r.json()).version || null;
Note: See TracChangeset for help on using the changeset viewer.