mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06:00
- Improve ETA calculation for big torrents
- Bump to v1.5.6
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
- BUGFIX: RSS feed downloader can only process unread articles now
|
- BUGFIX: RSS feed downloader can only process unread articles now
|
||||||
- BUGFIX: Fixed memory leak in RSS parser
|
- BUGFIX: Fixed memory leak in RSS parser
|
||||||
- BUGFIX: Fixed possible crash in search autocompletion
|
- BUGFIX: Fixed possible crash in search autocompletion
|
||||||
|
- BUGFIX: Improved ETA calculation for big torrents
|
||||||
|
|
||||||
* Wed Nov 4 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.5
|
* Wed Nov 4 2009 - Christophe Dumez <chris@qbittorrent.org> - v1.5.5
|
||||||
- BUGFIX: Fixed man page
|
- BUGFIX: Fixed man page
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Categories=Qt;Network;P2P;
|
Categories=Qt;Network;P2P;
|
||||||
Comment=V1.5.5
|
Comment=V1.5.6
|
||||||
Exec=qbittorrent %f
|
Exec=qbittorrent %f
|
||||||
GenericName=Bittorrent client
|
GenericName=Bittorrent client
|
||||||
GenericName[bg]=Торент клиент
|
GenericName[bg]=Торент клиент
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@@ -114,6 +114,8 @@ bittorrent::~bittorrent() {
|
|||||||
delete FSWatcher;
|
delete FSWatcher;
|
||||||
delete FSMutex;
|
delete FSMutex;
|
||||||
}
|
}
|
||||||
|
if(timerETA)
|
||||||
|
delete timerETA;
|
||||||
// Delete BT session
|
// Delete BT session
|
||||||
qDebug("Deleting session");
|
qDebug("Deleting session");
|
||||||
delete s;
|
delete s;
|
||||||
@@ -215,21 +217,64 @@ int bittorrent::getUpTorrentPriority(QString hash) const {
|
|||||||
return h.queue_position();
|
return h.queue_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the ETA using GASA
|
void bittorrent::takeETASamples() {
|
||||||
// GASA: global Average Speed Algorithm
|
bool change = false;;
|
||||||
qlonglong bittorrent::getETA(QString hash) const {
|
foreach(const QString &hash, ETA_samples.keys()) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
if(!h.is_valid()) return -1;
|
if(h.is_valid() && !h.is_paused() && !h.is_seed()) {
|
||||||
switch(h.state()) {
|
QList<int> samples = ETA_samples.value(h.hash(), QList<int>());
|
||||||
case torrent_status::downloading: {
|
if(samples.size() >= MAX_SAMPLES)
|
||||||
if(h.active_time() == 0)
|
samples.removeFirst();
|
||||||
return -1;
|
samples.append(h.download_payload_rate());
|
||||||
double avg_speed = (double)h.all_time_download() / h.active_time();
|
ETA_samples[h.hash()] = samples;
|
||||||
return (qlonglong) floor((double) (h.actual_size() - h.total_wanted_done()) / avg_speed);
|
change = true;
|
||||||
|
} else {
|
||||||
|
ETA_samples.remove(hash);
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
if(!change && timerETA) {
|
||||||
|
delete timerETA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This algorithm was inspired from KTorrent - http://www.ktorrent.org
|
||||||
|
// Calculate the ETA using a combination of several algorithms:
|
||||||
|
// GASA: Global Average Speed Algorithm
|
||||||
|
// CSA: Current Speed Algorithm
|
||||||
|
// WINX: Window of X Algorithm
|
||||||
|
qlonglong bittorrent::getETA(QString hash) {
|
||||||
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
|
if(!h.is_valid() || h.state() != torrent_status::downloading || !h.active_time())
|
||||||
|
return -1;
|
||||||
|
// See if the torrent is going to be completed soon
|
||||||
|
qulonglong bytes_left = h.actual_size() - h.total_wanted_done();
|
||||||
|
if(h.actual_size() > 10485760L) { // Size > 10MiB
|
||||||
|
if(h.progress() >= (float)0.99 && bytes_left < 10485760L) { // Progress>99% but less than 10MB left.
|
||||||
|
// Compute by taking samples
|
||||||
|
if(!ETA_samples.contains(h.hash())) {
|
||||||
|
ETA_samples[h.hash()] = QList<int>();
|
||||||
|
}
|
||||||
|
if(!timerETA) {
|
||||||
|
timerETA = new QTimer(this);
|
||||||
|
connect(timerETA, SIGNAL(timeout()), this, SLOT(takeETASamples()));
|
||||||
|
timerETA->start();
|
||||||
|
} else {
|
||||||
|
QList<int> samples = ETA_samples.value(h.hash(), QList<int>());
|
||||||
|
int nb_samples = samples.size();
|
||||||
|
if(nb_samples > 3) {
|
||||||
|
long sum_samples = 0;
|
||||||
|
foreach(int val, samples) {
|
||||||
|
sum_samples += val;
|
||||||
|
}
|
||||||
|
// Use WINX
|
||||||
|
return (qlonglong)(((double)bytes_left) / (((double)sum_samples) / ((double)nb_samples)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Normal case: Use GASA
|
||||||
|
double avg_speed = (double)h.all_time_download() / h.active_time();
|
||||||
|
return (qlonglong) floor((double) (bytes_left) / avg_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<torrent_handle> bittorrent::getTorrents() const {
|
std::vector<torrent_handle> bittorrent::getTorrents() const {
|
||||||
|
|||||||
@@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
#define MAX_SAMPLES 20
|
||||||
|
|
||||||
class downloadThread;
|
class downloadThread;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
@@ -77,6 +79,8 @@ class bittorrent : public QObject {
|
|||||||
bool queueingEnabled;
|
bool queueingEnabled;
|
||||||
QStringList url_skippingDlg;
|
QStringList url_skippingDlg;
|
||||||
QHash<QString, QString> savepath_fromurl;
|
QHash<QString, QString> savepath_fromurl;
|
||||||
|
QPointer<QTimer> timerETA;
|
||||||
|
QHash<QString, QList<int> > ETA_samples;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString getSavePath(QString hash);
|
QString getSavePath(QString hash);
|
||||||
@@ -107,7 +111,7 @@ class bittorrent : public QObject {
|
|||||||
int loadTorrentPriority(QString hash);
|
int loadTorrentPriority(QString hash);
|
||||||
QStringList getConsoleMessages() const;
|
QStringList getConsoleMessages() const;
|
||||||
QStringList getPeerBanMessages() const;
|
QStringList getPeerBanMessages() const;
|
||||||
qlonglong getETA(QString hash) const;
|
qlonglong getETA(QString hash);
|
||||||
bool useTemporaryFolder() const;
|
bool useTemporaryFolder() const;
|
||||||
QString getDefaultSavePath() const;
|
QString getDefaultSavePath() const;
|
||||||
|
|
||||||
@@ -177,6 +181,7 @@ class bittorrent : public QObject {
|
|||||||
void readAlerts();
|
void readAlerts();
|
||||||
void loadTrackerFile(QString hash);
|
void loadTrackerFile(QString hash);
|
||||||
void deleteBigRatios();
|
void deleteBigRatios();
|
||||||
|
void takeETASamples();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addedTorrent(QTorrentHandle& h);
|
void addedTorrent(QTorrentHandle& h);
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ CONFIG += qt \
|
|||||||
network
|
network
|
||||||
|
|
||||||
# Update this VERSION for each release
|
# Update this VERSION for each release
|
||||||
DEFINES += VERSION=\\\"v1.5.5\\\"
|
DEFINES += VERSION=\\\"v1.5.6\\\"
|
||||||
DEFINES += VERSION_MAJOR=1
|
DEFINES += VERSION_MAJOR=1
|
||||||
DEFINES += VERSION_MINOR=5
|
DEFINES += VERSION_MINOR=5
|
||||||
DEFINES += VERSION_BUGFIX=5
|
DEFINES += VERSION_BUGFIX=6
|
||||||
!mac:QMAKE_LFLAGS += -Wl,--as-needed
|
!mac:QMAKE_LFLAGS += -Wl,--as-needed
|
||||||
contains(DEBUG_MODE, 1) {
|
contains(DEBUG_MODE, 1) {
|
||||||
CONFIG += debug
|
CONFIG += debug
|
||||||
|
|||||||
Reference in New Issue
Block a user