Skip to content

K2GO-588 fix(download): the rootfs download is HTTP only, never BitTorrent - #813

Open
luisguzman-adfa wants to merge 3 commits into
mainfrom
chore/K2GO-588-remove-bittorrent
Open

luisguzman-adfa wants to merge 3 commits into
mainfrom
chore/K2GO-588-remove-bittorrent

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

What changes

The rootfs download is HTTP only. No BitTorrent, no DHT, no LPD, no peer exchange.

  • App (Aria2Manager): the app already fetches the .meta4 once. It now writes a local copy without the <metaurl> elements (MetalinkHttpOnly, pure domain) and gives aria2 that copy (--metalink-file), so aria2 does not read the URL again. aria2 runs with --enable-dht=false --enable-dht6=false --bt-enable-lpd=false --enable-peer-exchange=false. --seed-time=0 and dht.dat are removed; a leftover dht.dat is deleted. The IPv4 profiler uses the same copy and flags.
  • A .meta4 that cannot be read is reported as a network problem (Aria2Exit 6, TRANSIENT), so the caller offers a retry as before. It does not fall back to the URL, because that path is BitTorrent. A stop that the user latched in that window is still honored (shared postLatchedStop).
  • Builder: deletes the mkmetalink .torrent and removes the <metaurl> line before the bake signs the .meta4. New bakes publish an HTTP-only .meta4, so its sha-256 in the signed manifest matches the copy that aria2 reads (ADR A6 stays possible).
  • Workflow: comments only; old .torrent files on R2 are still pruned with their tarball.
  • ADR-K2GO-554 Amendment 3 (supersedes A4).

Why

K2GO-588: no data leaves the phone except what the user starts. The published .meta4 carries <metaurl mediatype="torrent">, and aria2 turns the download into a BitTorrent session (tracker announce, DHT, LPD). --follow-torrent=false does not stop this (measured in ADR A4).

Steps to QA

  1. Clear the app data, run the wizard, Internet download, Basic.
  2. adb logcat | grep IIAB-Aria2: the progress lines have no SD: field and the run never shows SEED. The log ends with Integrity verified ... sha-256 OK and Signature check ...: TRUSTED.
  3. Pause and resume the download: it resumes from the control file.
  4. Turn off the network before the download starts: the error is the "network problem" retry, not a fatal error.

Verifications

  • :app:lintStandardDebug, :app:testStandardDebugUnitTest, :app:assembleStandardDebug, :app:compileFdroidDebugJavaWithJavac: pass.
  • New unit test MetalinkHttpOnlyTest (5 cases: the published metaurl, the parsed result keeps mirrors/size/hash, self-closing and multiline metaurls, no metaurl, null).
  • Two-pass code review done. Pass 1 found that the early return on a failed .meta4 read would drop a latched pause or cancel; fixed with a shared helper. Pass 2: no new state (the local copy is rewritten for each download, in the cache); the .meta4 is fetched once instead of twice.
  • Before and after on a OnePlus 7T (Android 16), the app's bundled aria2, 12 s each, latest_basic_arm64-v8a.meta4 (build 2026.321):
    • Before (URL + old flags): [#70181c 537MiB/1.4GiB(35%) CN:1 SD:0 DL:48MiB]. The SD: field exists only in a BitTorrent session. An earlier full download with the old build ended in SEED(0.0).
    • After (HTTP-only copy + new flags): [#cfc8b4 562MiB/1.4GiB(37%) CN:1 DL:49MiB]. Same speed, no SD:.
  • End to end with this build on the 7T (data cleared, wizard, Basic): 0 progress lines with SD:, aria2 exit 0, Integrity verified ... (1590750919 bytes, sha-256 OK), Signature check ...: TRUSTED usize=2924728320.
  • The box (dash-node) aria2 for ZIM and maps has no BitTorrent flags, and the Kiwix .meta4 files have no metaurl (checked 2026-11-20). No change there.

Notes

  • Same ticket as PR 1 and PR 2 of K2GO-588. Independent of them (based on main).
  • No new permission or dependency. No UI change.

…rrent

The published .meta4 carries a torrent <metaurl>, and aria2 turned the
download into a BitTorrent session (it ended in the SEED state on a 7T).
--follow-torrent=false does not stop it (ADR-K2GO-554 A4). The app now gives
aria2 a local copy of the .meta4 without the metaurl (MetalinkHttpOnly), and
runs it with DHT, LPD and peer exchange off. The IPv4 profiler uses the same
copy. A .meta4 that cannot be read is reported as a network problem, and a
stop latched in that window is still honored.
….torrent

The builder deletes the mkmetalink .torrent and removes the <metaurl> line
before the bake signs the .meta4. Old .torrent files on R2 are pruned with
their tarball.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant