Progress of paused torrents is now correct on restart

This commit is contained in:
Christophe Dumez 2007-06-28 21:54:07 +00:00
parent 8755ebba01
commit 568b2ddf75
4 changed files with 25 additions and 3 deletions

View file

@ -18,6 +18,7 @@
- FEATURE: Better systems integration (buttons, dialogs...)
- 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)
- BUGFIX: Progress of paused torrents is now correct on restart
- COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little
- COSMETIC: Display more logs messages concerning features

View file

@ -478,9 +478,19 @@ void GUI::updateDlList(bool force){
try{
torrent_status torrentStatus = h.status();
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(finishedSHAs.indexOf(fileHash) != -1) continue;
int row = getRowFromHash(fileHash);
if(row == -1){
qDebug("Info: Could not find filename in download list, adding it...");
restoreInDownloadList(h);

View file

@ -125,6 +125,11 @@ void bittorrent::pauseTorrent(const QString& hash){
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
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
QFile::copy(file, newFile);
}
//qDebug("Copied to torrent backup directory");
// Pause torrent if it was paused last time
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
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
void bittorrent::setMaxConnections(int maxConnec){
s->set_max_connections(maxConnec);

View file

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