mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 06:17:58 +00:00
- Fixed progress for unchecked paused torrents
This commit is contained in:
parent
4f8825e371
commit
a1b133d883
@ -798,11 +798,10 @@ bool bittorrent::pauseTorrent(QString hash) {
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
paused_file.close();
|
||||
}
|
||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
paused_file.write(QByteArray::number((double)h.progress()));
|
||||
paused_file.close();
|
||||
// Remove it from TorrentsStartTime hash table
|
||||
if(calculateETA) {
|
||||
TorrentsStartTime.remove(hash);
|
||||
@ -1346,11 +1345,22 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
|
||||
}
|
||||
|
||||
float bittorrent::getUncheckedTorrentProgress(QString hash) const {
|
||||
/*if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"))
|
||||
return 1.;*/
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
|
||||
return (float)downUpInfo.first / (float)h.actual_size();
|
||||
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
|
||||
paused_file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
if(!paused_file.exists()) {
|
||||
return 0.;
|
||||
}
|
||||
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{
|
||||
|
@ -809,8 +809,7 @@ void DownloadingTorrents::torrentAdded(QTorrentHandle& h) {
|
||||
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
|
||||
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
|
||||
// Pause torrent if it was paused last time
|
||||
// Not using isPaused function because torrents are paused after checking now
|
||||
if(QFile::exists(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"))) {
|
||||
if(h.is_paused()) {
|
||||
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);
|
||||
setRowColor(row, QString::fromUtf8("red"));
|
||||
|
Loading…
Reference in New Issue
Block a user