Browse Source

Progress of paused torrents is now correct on restart

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
568b2ddf75
  1. 1
      Changelog
  2. 12
      src/GUI.cpp
  3. 13
      src/bittorrent.cpp
  4. 2
      src/bittorrent.h

1
Changelog

@ -18,6 +18,7 @@
- FEATURE: Better systems integration (buttons, dialogs...) - FEATURE: Better systems integration (buttons, dialogs...)
- FEATURE: Filtered files are not allocated on the hard-drive anymore (if FS is compatible) - FEATURE: Filtered files are not allocated on the hard-drive anymore (if FS is compatible)
- FEATURE: Added a way to link against static libtorrent (useful for deb packages) - FEATURE: Added a way to link against static libtorrent (useful for deb packages)
- BUGFIX: Progress of paused torrents is now correct on restart
- COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little - COSMETIC: Redesigned options a little
- COSMETIC: Display more logs messages concerning features - COSMETIC: Display more logs messages concerning features

12
src/GUI.cpp

@ -478,9 +478,19 @@ void GUI::updateDlList(bool force){
try{ try{
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
QString fileHash = QString(misc::toString(h.info_hash()).c_str()); QString fileHash = QString(misc::toString(h.info_hash()).c_str());
int row = getRowFromHash(fileHash);
if(BTSession.getTorrentsToPauseAfterChecking().indexOf(fileHash) != -1){
// Pause torrent if it finished checking and it is was supposed to be paused.
// This is a trick to see the progress of the pause torrents on startup
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
BTSession.pauseTorrent(fileHash);
continue;
}
}
if(h.is_paused()) continue; if(h.is_paused()) continue;
if(finishedSHAs.indexOf(fileHash) != -1) continue; if(finishedSHAs.indexOf(fileHash) != -1) continue;
int row = getRowFromHash(fileHash);
if(row == -1){ if(row == -1){
qDebug("Info: Could not find filename in download list, adding it..."); qDebug("Info: Could not find filename in download list, adding it...");
restoreInDownloadList(h); restoreInDownloadList(h);

13
src/bittorrent.cpp

@ -125,6 +125,11 @@ void bittorrent::pauseTorrent(const QString& hash){
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"); QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text); paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close(); paused_file.close();
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
qDebug("A torrent was paused just after checking, good");
}
} }
} }
@ -240,10 +245,10 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString
// Copy it to torrentBackup directory // Copy it to torrentBackup directory
QFile::copy(file, newFile); QFile::copy(file, newFile);
} }
//qDebug("Copied to torrent backup directory");
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")){
h.pause(); torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
} }
// Incremental download // Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")){ if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")){
@ -296,6 +301,10 @@ void bittorrent::addTorrent(const QString& path, bool fromScanDir, const QString
} }
} }
QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
return torrentsToPauseAfterChecking;
}
// Set the maximum number of opened connections // Set the maximum number of opened connections
void bittorrent::setMaxConnections(int maxConnec){ void bittorrent::setMaxConnections(int maxConnec){
s->set_max_connections(maxConnec); s->set_max_connections(maxConnec);

2
src/bittorrent.h

@ -57,6 +57,7 @@ class bittorrent : public QObject{
downloadThread *downloader; downloadThread *downloader;
QStringList supported_preview_extensions; QStringList supported_preview_extensions;
QString defaultSavePath; QString defaultSavePath;
QStringList torrentsToPauseAfterChecking;
protected: protected:
QString getSavePath(const QString& hash); QString getSavePath(const QString& hash);
@ -76,6 +77,7 @@ class bittorrent : public QObject{
QList<torrent_handle> getFinishedTorrentHandles() const; QList<torrent_handle> getFinishedTorrentHandles() const;
session_status getSessionStatus() const; session_status getSessionStatus() const;
int getListenPort() const; int getListenPort() const;
QStringList getTorrentsToPauseAfterChecking() const;
public slots: public slots:
void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString()); void addTorrent(const QString& path, bool fromScanDir = false, const QString& from_url = QString());

Loading…
Cancel
Save