Repository navigation
feat(metalink): download Metalinks from all their mirrors at once - #585
Conversation
Adds library:metalink with MetalinkDownloadSource, which reads Metalink 4 (.meta4) and Metalink 3 (.metalink) links and dropped files and downloads the file from every HTTP(S) mirror they list at once. Core gains MirrorDownloadHelper: segments are fetched from the least busy mirror, a failed segment continues on another mirror from the byte it reached, pieces that fail their hashes are refetched from other mirrors after the mirrors that sent them are dropped, and Ketch verifies the whole file against the Metalink's strongest hash. A Metalink listing several files offers them as a single choice, saved under the chosen file's own name (SourceFile.FILE_NAME_KEY). The apps and the CLI register the source, the add sheet keeps one file checked for single-choice rows, and dropped .meta4/.metalink files open the add sheet like .torrent files.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69e328902c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…alink-mirrors # Conflicts: # AGENTS.md
…alink-mirrors # Conflicts: # AGENTS.md
…alink-mirrors # Conflicts: # AGENTS.md # README.md # cli/README.md
…alink-mirrors # Conflicts: # AGENTS.md # README.de.md # README.es.md # README.fr.md # README.ja.md # README.md # README.zh-CN.md # app/android/build.gradle.kts # app/android/src/main/kotlin/com/linroid/ketch/app/android/KetchService.kt # app/desktop-native/build.gradle.kts # app/desktop-native/src/main/kotlin/com/linroid/ketch/app/nativeimage/Main.kt # app/desktop/build.gradle.kts # app/desktop/src/main/kotlin/com/linroid/ketch/app/desktop/main.kt # app/shared/build.gradle.kts # app/shared/src/iosMain/kotlin/com/linroid/ketch/app/MainViewController.kt # cli/build.gradle.kts # cli/src/main/kotlin/com/linroid/ketch/cli/Main.kt # docs/architecture.md # docs/developers.md # settings.gradle.kts
Summary
Implements the Metalink roadmap item: downloads from several mirrors at once, with checksums and piece verification.
library:metalink(new published module, same targets as core):MetalinkDownloadSourcereads Metalink 4 (.meta4, RFC 5854) and Metalink 3 (.metalink) from links and dropped/opened files. The parsed document is kept with the task (METAINFO_KEY), so resumes never fetch it again. It comes with a small XML reader that refuses DOCTYPE declarations and limits nesting, element count and document size (8 MiB).MirrorDownloadHelper(com.linroid.ketch.core.mirror):RetryPolicy, so a one-mirror Metalink behaves like plain HTTP.publishedChecksum); a mismatch isChecksumMismatch.FileSelectionMode.SINGLEchoice, the first built-in source to use it. NewSourceFile.FILE_NAME_KEYmakes the chosen file save under its own name. Choosing another file is refused once the task has an output path.KetchFeatures.METALINK(download.metalink) andSourceFile.FILE_NAME_KEY(API dump updated)..meta4/.metalinkfiles open the add sheet like.torrentfiles. The add sheet keeps exactly one file checked for single-choice rows and hides "Download all".:library:metalink:testAndroidHostTest.Limits
.meta4files.Linkheaders (RFC 6249) download as plain HTTP.Snapshots
The add sheet for a
.meta4link listing three files. Before, every file was checked and "Download all" was offered, and Ketch refuses that selection for a single-choice source. After, one file is chosen and saved under its own name.Testing
MirrorDownloadHelperTest(core): spreading across mirrors and priorities, header scoping, refusing and mid-transfer failover, corrupt-piece repair, failing after repairs, last-mirror rethrow, resuming saved segments.MetalinkTestandMetalinkDownloadSourceTest: v4/v3 parsing, HTTPS downgrade rule, invalid pieces, malformed XML and DOCTYPE, canHandle, URL/content resolve, size probing, downloading the chosen file, selection rules.MetalinkKetchTest(jvmTest): a wholeKetchdownloading to disk from three mirrors with checksum verification, the chosen file saved under its name, and a wrong whole-file hash failing asChecksumMismatch.IntakeSingleChoiceTest(app).:library:metalink:allTests,testAndroidHostTest,:library:core:jvmTest, iOS test compilation,:app:shared:jvmTest(intake),:app:android:compileDirectDebugKotlin,:app:shared:compileKotlinIosSimulatorArm64,:cli:compileKotlin,:app:desktop:compileKotlin.