| … | … | @@ -323,11 +323,15 @@ export { chooseBundle } from './choose-bundle.js' |
| 323 | 323 | * has no sidecar and never will, so the probe is pure latency — and SELinux makes pathname sockets their |
| 324 | 324 | * own hazard here. |
| 325 | 325 | */ |
| 326 | | export async function swarmFetcher ({ registryKeyHex = DEFAULT_REGISTRY, repo = DEFAULT_REPO, timeout = 120000, destDir = null, swarm = null } = {}) { |
| 326 | export async function swarmFetcher ({ registryKeyHex = DEFAULT_REGISTRY, repo = DEFAULT_REPO, timeout = 120000, destDir = null, swarm = null, storeDir = null } = {}) { |
| 327 | 327 | const { makeGetLatestRelease } = await import('pgh/resolve-release') |
| 328 | 328 | const { NetworkFetcher } = await import('pgh/network-fetcher') |
| 329 | 329 | |
| 330 | | const getLatestRelease = makeGetLatestRelease({ registryKeyHex, preferSidecar: false }) |
| 330 | // ⛔ storeDir, OR THE REGISTRY REPLICA GOES TO A HOME DIRECTORY THAT DOES NOT EXIST HERE. |
| 331 | // Measured on a handset: ENOENT stat'ing the default path, caught into "no swarm fetcher — |
| 332 | // updates disabled this boot". The phone could never update and said so only once the app was |
| 333 | // taught to surface its own last OTA line. |
| 334 | const getLatestRelease = makeGetLatestRelease({ registryKeyHex, preferSidecar: false, storeDir }) |
| 331 | 335 | const latest = await getLatestRelease(repo) |
| 332 | 336 | if (!latest || !latest.serverKey) throw new Error('no published release with a serverKey for ' + repo) |
| 333 | 337 | |
| … | … | @@ -371,7 +375,13 @@ export async function startOta ({ storage, say = () => {}, repo = DEFAULT_REPO, |
| 371 | 375 | let fetcher = injectedFetcher |
| 372 | 376 | if (!fetcher) { |
| 373 | 377 | try { |
| 374 | | ;({ fetcher } = await swarmFetcher({ registryKeyHex, repo, destDir: path.join(dir, '.fetch'), swarm })) |
| 378 | // ⛔ `storeDir` UNDER THIS APP'S STORAGE. Without it the registry replica goes to a path |
| 379 | // derived from the home directory, which Android does not have — measured on a handset as |
| 380 | // ENOENT, surfacing as "no swarm fetcher — updates disabled this boot". A phone that could |
| 381 | // never update, for a reason nothing on the device could show until now. |
| 382 | ;({ fetcher } = await swarmFetcher({ |
| 383 | registryKeyHex, repo, destDir: path.join(dir, '.fetch'), swarm, storeDir: path.join(dir, 'registry') |
| 384 | })) |
| 375 | 385 | } catch (err) { |
| 376 | 386 | say('ota: no swarm fetcher — updates disabled this boot (' + ((err && err.message) || err) + ')') |
| 377 | 387 | return null |