-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
QBittorrent进度验证使用种子总大小而不是选中大小 #700
Conversation
WalkthroughThe Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java (1)
Line range hint
115-115
: Consider documenting the progress calculation formulaSince the progress verification now uses
totalSize
, it would be valuable to document the exact formula used for progress calculation (progress * totalSize = expected downloaded amount) to ensure consistent implementation across the codebase.Consider adding a comment above the progress field:
@SerializedName("progress") + // Progress as a percentage (0.0 to 1.0) of totalSize private double progress;
Also applies to: 190-190
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java
(1 hunks)
🔇 Additional comments (2)
src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java (2)
Line range hint 1-186
: Clean code improvement: Removed unused fields
The removal of commented-out fields improves code readability while maintaining all necessary functionality. The class structure remains clean with proper use of Lombok and GSON annotations.
190-190
: Correct implementation: Using total torrent size for accurate progress tracking
The change to return totalSize
instead of size
is the right approach for accurate progress verification. This prevents false bans when users download selected files, as it compares progress against the complete torrent size.
Let's verify that this change doesn't conflict with other torrent implementations:
✅ Verification successful
Change to use totalSize is consistent with other implementations
The change from size
to totalSize
in QBittorrentTorrent is correct and aligns with other implementations:
- Transmission implementation uses
getTotalSize()
- QBittorrent now uses
totalSize
- Both consistently return the complete torrent size
The TorrentImpl is just a basic implementation and not a real downloader client implementation, so its use of size
doesn't impact this change.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other implementations of the Torrent interface
# to ensure consistent size calculation across different clients
# Look for interface definition
echo "Checking Torrent interface definition:"
rg "interface.*Torrent.*\{" -A 10
# Look for other implementations
echo -e "\nChecking other Torrent implementations:"
ast-grep --pattern 'class $_ implements Torrent'
Length of output: 3207
Script:
#!/bin/bash
# Let's search for all Java files that implement the Torrent interface and check their getSize() methods
echo "Searching for Torrent implementations:"
fd -e java | xargs rg "class.*implements.*Torrent" -l
echo -e "\nChecking getSize() method implementations:"
ast-grep --pattern 'public $_ getSize() {
$$$
}'
# Also search for size-related method definitions in the Torrent interface
echo -e "\nChecking size-related methods in Torrent interface:"
rg "getSize|size" src/main/java/com/ghostchu/peerbanhelper/torrent/Torrent.java
Length of output: 895
Script:
#!/bin/bash
# Let's examine the getSize() implementations in each torrent implementation file
echo "QBittorrent implementation:"
rg "getSize" src/main/java/com/ghostchu/peerbanhelper/downloader/impl/qbittorrent/impl/QBittorrentTorrent.java -B 2 -A 2
echo -e "\nTransmission implementation:"
rg "getSize" src/main/java/com/ghostchu/peerbanhelper/downloader/impl/transmission/TRTorrent.java -B 2 -A 2
echo -e "\nDeluge implementation:"
rg "getSize" src/main/java/com/ghostchu/peerbanhelper/downloader/impl/deluge/DelugeTorrent.java -B 2 -A 2
echo -e "\nTorrentImpl implementation:"
rg "getSize" src/main/java/com/ghostchu/peerbanhelper/torrent/TorrentImpl.java -B 2 -A 2
Length of output: 926
请详细说明此PR并提供误封的例子 |
nice catch |
使用选中的大小计算peer进度时,会导致算出的进度与peer汇报的进度不一致,导致误封
Summary by CodeRabbit
New Features
Bug Fixes