mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-03-02 22:57:32 -05:00
flawed calculation of first and last file pieces #321
Labels
No labels
Accessibility
AppImage
Bounty
Build system
CI
Can't reproduce
Code cleanup
Confirmed bug
Confirmed bug
Core
Crash
Data loss
Discussion
Docker
Documentation
Duplicate
Feature
Feature request
Feature request
Feature request
Filters
Flatpak
GUI
Has workaround
I2P
Invalid
Libtorrent
Look and feel
Meta
NSIS
Network
Not an issue
OS: *BSD
OS: Linux
OS: Windows
OS: macOS
PPA
Performance
Project management
Proxy/VPN
Qt bugs
Qt6 compat
RSS
Search engine
Security
Temp folder
Themes
Translations
Triggers
Waiting diagnosis
Waiting info
Waiting upstream
Waiting web implementation
Watched folders
WebAPI
WebUI
autoCloseOldIssue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/qBittorrent#321
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @integer-division-what on GitHub (Jan 27, 2013).
There are some flaws in the piece calculations starting around line 65 of src/qtlibtorrent/qtorrenthandle.cpp.
First, integer division should be used, as its much cleaner. No need for messy floats.
Second, the calculation of num_pieces_in_file is incorrect in some cases when the file starts near the end of a piece. But it's unnecessary to compute this number anyway-- last_piece can be computed directly.
Third, some files need more than just their last piece in order to be previewable. For instance, some retarded mp4 files need almost 1% of the tail of the file in order to play. So I propose that the first and last 1% of each file be prioritized. Something like the following:
int first_piece1 = file.offset / piece_size;
int first_piece2 = (file.offset + file.size / 100) / piece_size;
int last_piece1 = (file.offset + file.size - 1 - file.size / 100) / piece_size;
int last_piece2 = (file.offset + file.size - 1) / piece_size;
Then set the priority on the pieces in the ranges [first_piece1, first_piece2] and [last_piece1, last_piece2].
@Gelmir commented on GitHub (Jan 27, 2013):
Partially resolved in pull #189 which is kind of old
@thalieht commented on GitHub (Jan 24, 2017):
@ngosang close?
@ngosang commented on GitHub (Jan 25, 2017):
Already fixed in #3816