Skip to content

feat(torrent): download chosen files before the others - #673

Merged
linroid merged 3 commits into
mainfrom
feat/torrent-file-priority
Nov 14, 2026
Merged

linroid merged 3 commits into
mainfrom
feat/torrent-file-priority

Conversation

@linroid

@linroid linroid commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Stacked on #672 (files in place); only the last commit belongs to this PR.

What

The "Scheduling: per-file priorities" row of #162.

  • API: TorrentController.priorityFiles(taskId) and setPriorityFiles(taskId, fileIds) name the files a task downloads before its others (capability file-priority); TorrentFileEntry.priority marks them in file pages. An ID the torrent does not list is invalid_input. It orders the download and never selects a file.
  • Engine: the choice becomes a piece bitmap, read live. The v1 scheduler opens those pieces before any other and the v2 loop begins them first, each still in order or rarest first, falling back to the rest once a peer has none of them left. Saved with the task, so it survives a restart.
  • Server and remote: GET and PUT /api/torrents/{id}/priority; the remote controller fails closed without the capability.
  • Apps: a bolt button on unfinished, selected files and folders in a downloading torrent's Files tab. Translated in every language.

Snapshots

New control, so there is no before. Episodes 10 and 11 are set to download first.

Light Dark

Testing

TorrentPieceSchedulerTest (priority pieces open before a rarer one, then the usual order), TorrentV2RarityPickerTest, KetchTorrentControllerTest, TorrentRoutesTest, RemoteTorrentControllerTest, FileSelectionModelTest (toggling, and a refusal undone). Core, torrent, remote, server, app and CLI suites pass on this branch, with iOS and WasmJs compiles.

Not covered: a transfer-level test that a real swarm delivers the chosen file first; the pickers are tested in isolation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T05:09:02.667849Z c51f564 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c51f564373

ℹ️ 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".

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 2 298 files   2 326 suites   58m 46s ⏱️
16 281 tests 15 995 ✅ 285 💤 1 ❌
19 818 runs  19 532 ✅ 285 💤 1 ❌

For more details on these failures, see this check.

Results for commit 0d67080.

♻️ This comment has been updated with latest results.

@linroid
linroid force-pushed the feat/torrent-file-priority branch from 010e5cd to 0d67080 Compare November 14, 2026 11:49
Base automatically changed from feat/torrent-adopt-files to main November 14, 2026 12:28
@linroid
linroid force-pushed the feat/torrent-file-priority branch from 0d67080 to 2d758e8 Compare November 14, 2026 12:28
@linroid
linroid merged commit 33b8fd9 into main Nov 14, 2026
@linroid
linroid deleted the feat/torrent-file-priority branch November 14, 2026 12:32
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