| … | … | @@ -363,8 +363,23 @@ export async function swarmFetcher ({ registryKeyHex = DEFAULT_REGISTRY, repo = |
| 363 | 363 | // ⚠ The cost is a slow check, not a slow boot: startOta is awaited but non-fatal, the interval is |
| 364 | 364 | // hours, and a check that answers in 30s having actually replicated beats one that answers in |
| 365 | 365 | // 500ms having seen nothing. |
| 366 | // ⛔ ITS OWN storeDir, AND IT MUST HAVE ONE. This closure is not only used here: swarmFetcher |
| 367 | // REPLACES `fetcher.getLatestRelease` with it, and pgh-runtime calls that on every `_check()` — |
| 368 | // so it resolves long after this function returns. Passing `latest` skips the call HERE and does |
| 369 | // nothing for the calls pgh-runtime makes later. |
| 370 | // |
| 371 | // ⛔ AND IT MUST NOT BE THE WATCH'S DIRECTORY. RocksDB's lock is exclusive; sharing the path the |
| 372 | // watch holds fails with "File descriptor could not be locked". Dropping storeDir entirely to |
| 373 | // avoid that — which is what I did — sent it to `homedir()/.config/pgh/registries`, and on Android |
| 374 | // that cannot be created, so every `_check()` threw ENOENT. A separate directory satisfies both. |
| 375 | // |
| 376 | // MEASURED with HOME pointed at an uncreatable path, which reproduces the handset exactly: |
| 377 | // resolveRelease < NetworkFetcher.getLatestRelease < PghRuntime._check < PghRuntime.start |
| 366 | 378 | const getLatestRelease = makeGetLatestRelease({ |
| 367 | | registryKeyHex, preferSidecar: false, storeDir, settleMs: COLD_SETTLE_MS |
| 379 | registryKeyHex, |
| 380 | preferSidecar: false, |
| 381 | storeDir: storeDir || (destDir ? path.join(destDir, '..', 'registry-check') : undefined), |
| 382 | settleMs: COLD_SETTLE_MS |
| 368 | 383 | }) |
| 369 | 384 | const latest = opts_latest || await getLatestRelease(repo) |
| 370 | 385 | if (!latest || !latest.serverKey) throw new Error('no published release with a serverKey for ' + repo) |