Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TorrentDownloadController #1208

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

StageGuard
Copy link
Member

TorrentDownloaderController 无法工作

@StageGuard
Copy link
Member Author

will also close #1205

@Him188 Him188 linked an issue Nov 16, 2024 that may be closed by this pull request
Copy link
Member

@Him188 Him188 left a comment

Choose a reason for hiding this comment

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

add unit tests

@Him188 Him188 added this to the 4.0.0 milestone Nov 16, 2024
@Him188 Him188 added the s: torrent 子系统: BT label Nov 16, 2024
totalSize = 1000.kb,
pieceSize = 1.kb,
initialDataOffset = 0,
initialPieceIndex = 0,
Copy link
Member

@Him188 Him188 Nov 17, 2024

Choose a reason for hiding this comment

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

还需要测试有这个 initialPieceIndex 的情况, 否则你没有测试这个 PR 尝试解决的问题 #1205

finishPiece(100)
assertEquals(listOf(2, 3, 4, 6, 7, 8, 9, 10, 11, 13, 997, 998, 999), currentDownloadingPieces.sorted())

// 不会重复请求已经完成的 piece
Copy link
Member

Choose a reason for hiding this comment

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

separate case

(10..99).forEach { finishPiece(it) }
assertEquals(listOf(2, 3, 4, 6, 7, 8, 9, 101, 102, 103, 997, 998, 999), currentDownloadingPieces.sorted())

// seek 到 200, seek 后面的地方不会请求 footer
Copy link
Member

Choose a reason for hiding this comment

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

separate case

finishPiece(996)
controller.onSeek(100)
assertEquals(listOf(995, 997), currentDownloadingPieces.sorted())
}
Copy link
Member

Choose a reason for hiding this comment

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

没有测试有 overlap 的 seek.

例如:

  1. seek 100 -> seek 102
  2. seek 100 -> seek 98
  3. seek 990 (footer 范围内) -> seek 985. 期望 footer 仍然在 window 内
  4. seek 1 (header 范围内) -> seek 20. 期望 header 仍然在 window 内

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: torrent 子系统: BT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

程序启动时报错:IndexOutOfBoundsException
2 participants