|
|
@ -370,6 +370,7 @@ int bittorrent::getUpTorrentPriority(QString hash) const { |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::updateUploadQueue() { |
|
|
|
void bittorrent::updateUploadQueue() { |
|
|
|
Q_ASSERT(queueingEnabled); |
|
|
|
Q_ASSERT(queueingEnabled); |
|
|
|
|
|
|
|
bool change = false; |
|
|
|
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads; |
|
|
|
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads; |
|
|
|
int currentActiveUploads = 0; |
|
|
|
int currentActiveUploads = 0; |
|
|
|
// Check if it is necessary to queue uploads
|
|
|
|
// Check if it is necessary to queue uploads
|
|
|
@ -381,6 +382,7 @@ void bittorrent::updateUploadQueue() { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Queue it
|
|
|
|
// Queue it
|
|
|
|
h.pause(); |
|
|
|
h.pause(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
if(!queuedUploads->contains(hash)) { |
|
|
|
if(!queuedUploads->contains(hash)) { |
|
|
|
queuedUploads->append(hash); |
|
|
|
queuedUploads->append(hash); |
|
|
|
// Create .queued file
|
|
|
|
// Create .queued file
|
|
|
@ -395,6 +397,7 @@ void bittorrent::updateUploadQueue() { |
|
|
|
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) { |
|
|
|
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) { |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
h.resume(); |
|
|
|
h.resume(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
queuedUploads->removeAll(hash); |
|
|
|
queuedUploads->removeAll(hash); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
++currentActiveUploads; |
|
|
|
++currentActiveUploads; |
|
|
@ -408,6 +411,7 @@ void bittorrent::updateUploadQueue() { |
|
|
|
if(uploadQueue->contains(hash)) { |
|
|
|
if(uploadQueue->contains(hash)) { |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
h.resume(); |
|
|
|
h.resume(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
queuedUploads->removeAll(hash); |
|
|
|
queuedUploads->removeAll(hash); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
++currentActiveUploads; |
|
|
|
++currentActiveUploads; |
|
|
@ -417,10 +421,13 @@ void bittorrent::updateUploadQueue() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(change) |
|
|
|
|
|
|
|
emit updateFinishedTorrentNumber(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void bittorrent::updateDownloadQueue() { |
|
|
|
void bittorrent::updateDownloadQueue() { |
|
|
|
Q_ASSERT(queueingEnabled); |
|
|
|
Q_ASSERT(queueingEnabled); |
|
|
|
|
|
|
|
bool change = false; |
|
|
|
currentActiveDownloads = 0; |
|
|
|
currentActiveDownloads = 0; |
|
|
|
// Check if it is necessary to queue torrents
|
|
|
|
// Check if it is necessary to queue torrents
|
|
|
|
foreach(QString hash, *downloadQueue) { |
|
|
|
foreach(QString hash, *downloadQueue) { |
|
|
@ -431,6 +438,7 @@ void bittorrent::updateDownloadQueue() { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Queue it
|
|
|
|
// Queue it
|
|
|
|
h.pause(); |
|
|
|
h.pause(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
if(!queuedDownloads->contains(hash)) { |
|
|
|
if(!queuedDownloads->contains(hash)) { |
|
|
|
queuedDownloads->append(hash); |
|
|
|
queuedDownloads->append(hash); |
|
|
|
// Create .queued file
|
|
|
|
// Create .queued file
|
|
|
@ -445,6 +453,7 @@ void bittorrent::updateDownloadQueue() { |
|
|
|
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) { |
|
|
|
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) { |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
h.resume(); |
|
|
|
h.resume(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
queuedDownloads->removeAll(hash); |
|
|
|
queuedDownloads->removeAll(hash); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
++currentActiveDownloads; |
|
|
|
++currentActiveDownloads; |
|
|
@ -458,6 +467,7 @@ void bittorrent::updateDownloadQueue() { |
|
|
|
if(downloadQueue->contains(hash)) { |
|
|
|
if(downloadQueue->contains(hash)) { |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = getTorrentHandle(hash); |
|
|
|
h.resume(); |
|
|
|
h.resume(); |
|
|
|
|
|
|
|
change = true; |
|
|
|
queuedDownloads->removeAll(hash); |
|
|
|
queuedDownloads->removeAll(hash); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"); |
|
|
|
++currentActiveDownloads; |
|
|
|
++currentActiveDownloads; |
|
|
@ -467,6 +477,8 @@ void bittorrent::updateDownloadQueue() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(change) |
|
|
|
|
|
|
|
emit updateUnfinishedTorrentNumber(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Calculate the ETA using GASA
|
|
|
|
// Calculate the ETA using GASA
|
|
|
|