feat(explore): refuse 0.6 GB on someone's mobile data
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:
@@ -508,6 +508,31 @@ selected as a literal `0`. Adding the column to the importer's SELECT
|
||||
list without that is how a published artifact — which nobody can re-cut
|
||||
retroactively — starts failing with `no such column`.
|
||||
|
||||
**A 0.6 GB download asks about the connection first.** `explore`'s
|
||||
catalog artifact had no network awareness at all, which on a phone is a
|
||||
month's data allowance spent without being asked (plan 016 B4).
|
||||
`netpolicy.go` is the gate, and its shape is dictated by one constraint:
|
||||
`explore` is imported by `cmd/indexbuild`, which is built with
|
||||
`CGO_ENABLED=0` and must not link Wails — so the *policy* and the
|
||||
*parsing* live here and are tested on every platform, while the platform
|
||||
call is a closure injected from `app.go`. It is
|
||||
`application.Mobile.NetworkJSON()`, not `application.Android`'s: the
|
||||
latter exists only under the `android` build tag, and `Mobile`'s desktop
|
||||
implementation is a stub returning `""`.
|
||||
|
||||
Three rules in it are load-bearing. **An unknown answer is not a metered
|
||||
one** — only mobile answers at all, so treating silence as metered would
|
||||
refuse the download on every desktop. **Cellular is the only signal
|
||||
available**: the runtime reports `wifi|cellular|ethernet|none` and no
|
||||
metered flag, so a metered *Wi-Fi* (a hotspot, a hotel) cannot be
|
||||
detected and is not refused, which is a documented gap rather than an
|
||||
oversight. And **the gate runs before anything is staged**, so declining
|
||||
is a no-op rather than a job in the indicator and a status the user has
|
||||
to dismiss. The permission (`AllowMeteredCatalogDownload`, default
|
||||
false, so an existing config is careful without a migration) is read at
|
||||
the moment a download would start, so turning it on takes effect on the
|
||||
next attempt rather than the next launch.
|
||||
|
||||
**Background work yields, and says so in the context.** The post-scan
|
||||
backfills share MusicBrainz's rate limiters with every page the user
|
||||
can open, and both were FIFO — so a thousand-artist enrichment put an
|
||||
|
||||
Reference in New Issue
Block a user