feat(explore): refuse 0.6 GB on someone's mobile data
CI / check (push) Canceled after 0s
CI / e2e (push) Canceled after 0s
Search index maintenance / maintain-index (push) Canceled after 0s
Build & publish Arch package / arch-package (push) Successful in 2m30s

Plan 016 B4. The catalog artifact is about 0.6 GB and the app fetched it
with no awareness of the connection: on a desktop that is a minute of
bandwidth, on a phone it can be a month's allowance. It is now skipped on
a cellular connection unless `AllowMeteredCatalogDownload` is on, with
the toggle in Settings' Search Index section, where the text explaining
what the catalog is already lives.

The file layout is dictated by the cgo rule rather than by taste.
`explore` is imported by `cmd/indexbuild`, which builds with
CGO_ENABLED=0 and must not link Wails, so `netpolicy.go` holds the policy
and the JSON parsing -- tested on every platform -- and the single
platform call is a closure injected from `app.go`, which already names
`application` legitimately.

Three rules in it are load-bearing. An unknown answer is not a metered
one: only mobile answers at all, and treating silence as metered would
have disabled the download for every desktop user in the world. Cellular
is the only signal available, because the runtime reports
`wifi|cellular|ethernet|none` and no metered flag -- so a metered Wi-Fi
cannot be detected and is not refused, which is documented rather than
implied. And the gate runs before the first status write, so declining is
a no-op instead of a job in the indicator and an error tier to dismiss.

Two corrections to the plan while implementing it: the portable API is
`application.Mobile.NetworkJSON()`, not `application.Android`'s, which
exists only under the `android` build tag; and the permission is read at
the moment a download would start, so enabling it takes effect on the
next attempt rather than the next launch.
This commit is contained in:
2026-08-17 10:48:00 -04:00
parent 2c78b58207
commit de2b324e20
12 changed files with 527 additions and 8 deletions
@@ -17,6 +17,14 @@ import * as download$0 from "../download/models.js";
// @ts-ignore: Unused imports
import * as tracklist$0 from "../tracklist/models.js";
/**
* GetAllowMeteredCatalogDownload reports whether the ~0.6 GB Explore
* catalog may be fetched on a metered connection.
*/
export function GetAllowMeteredCatalogDownload(): $CancellablePromise<boolean> {
return $Call.ByID(2258585139);
}
/**
* GetDefaultPage returns the view the app opens to on launch.
*/
@@ -127,6 +135,17 @@ export function Save(): $CancellablePromise<void> {
return $Call.ByID(1988945736);
}
/**
* SetAllowMeteredCatalogDownload saves the metered-download permission.
*
* There is nothing to validate and nothing to restart: the policy is
* read at the moment a download would start, so turning it on takes
* effect on the next attempt rather than needing this launch to be over.
*/
export function SetAllowMeteredCatalogDownload(allow: boolean): $CancellablePromise<void> {
return $Call.ByID(192700351, allow);
}
/**
* SetDefaultPage validates and saves a new launch page.
*/