1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-09 14:27:56 +00:00

- Fixed progress for unchecked paused torrents

This commit is contained in:
Christophe Dumez 2008-09-30 18:37:05 +00:00
parent 4f8825e371
commit a1b133d883
2 changed files with 21 additions and 12 deletions

View File

@ -798,11 +798,10 @@ bool bittorrent::pauseTorrent(QString hash) {
} }
} }
// Create .paused file if necessary // Create .paused file if necessary
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) { 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.write(QByteArray::number((double)h.progress()));
paused_file.close(); paused_file.close();
}
// Remove it from TorrentsStartTime hash table // Remove it from TorrentsStartTime hash table
if(calculateETA) { if(calculateETA) {
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
@ -1346,11 +1345,22 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
} }
float bittorrent::getUncheckedTorrentProgress(QString hash) const { float bittorrent::getUncheckedTorrentProgress(QString hash) const {
/*if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
return 1.;*/ paused_file.open(QIODevice::ReadOnly | QIODevice::Text);
QTorrentHandle h = getTorrentHandle(hash); if(!paused_file.exists()) {
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0)); return 0.;
return (float)downUpInfo.first / (float)h.actual_size(); }
QByteArray progress_char = paused_file.readAll();
qDebug("Read progress: %s", (const char*)progress_char.data());
paused_file.close();
bool ok = false;
float progress = progress_char.toFloat(&ok);
if(!ok) {
qDebug("Error converting progress in .paused file!");
return 0.;
}
qDebug("Unchecked torrent progress is %f", progress);
return progress;
} }
float bittorrent::getRealRatio(QString hash) const{ float bittorrent::getRealRatio(QString hash) const{

View File

@ -809,8 +809,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1)); DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash)); DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time // Pause torrent if it was paused last time
// Not using isPaused function because torrents are paused after checking now if(h.is_paused()) {
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"))) {
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash))); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)BTSession->getUncheckedTorrentProgress(hash)));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole); DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/paused.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("red")); setRowColor(row, QString::fromUtf8("red"));