Browse Source

- a lot of fixes concerning the new queueing system

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
4fe7fd537d
  1. 2
      src/GUI.cpp
  2. 30
      src/bittorrent.cpp

2
src/GUI.cpp

@ -1200,7 +1200,7 @@ void GUI::togglePausedState(QString hash) {
if(tabs->currentIndex() == 1) if(tabs->currentIndex() == 1)
inDownloadList = false; inDownloadList = false;
QTorrentHandle h = BTSession->getTorrentHandle(hash); QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(BTSession->isPaused(hash)) { if(BTSession->isPaused(hash) && !(BTSession->isQueueingEnabled() && (BTSession->isDownloadQueued(hash) || BTSession->isUploadQueued(hash)))) {
BTSession->resumeTorrent(hash); BTSession->resumeTorrent(hash);
downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name())); downloadingTorrentTab->setInfoBar(tr("'%1' resumed.", "e.g: xxx.avi resumed.").arg(h.name()));
if(inDownloadList) { if(inDownloadList) {

30
src/bittorrent.cpp

@ -429,7 +429,7 @@ void bittorrent::updateUploadQueue() {
// Could not fill download slots, unqueue torrents // Could not fill download slots, unqueue torrents
foreach(QString hash, *uploadQueue) { foreach(QString hash, *uploadQueue) {
if(uploadQueue->size() != 0 && currentActiveUploads < maxActiveUploads) { if(uploadQueue->size() != 0 && currentActiveUploads < maxActiveUploads) {
if(uploadQueue->contains(hash)) { if(queuedUploads->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.resume(); h.resume();
change = true; change = true;
@ -485,7 +485,7 @@ void bittorrent::updateDownloadQueue() {
// Could not fill download slots, unqueue torrents // Could not fill download slots, unqueue torrents
foreach(QString hash, *downloadQueue) { foreach(QString hash, *downloadQueue) {
if(downloadQueue->size() != 0 && currentActiveDownloads < maxActiveDownloads) { if(downloadQueue->size() != 0 && currentActiveDownloads < maxActiveDownloads) {
if(downloadQueue->contains(hash)) { if(queuedDownloads->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
h.resume(); h.resume();
change = true; change = true;
@ -738,9 +738,22 @@ bool bittorrent::pauseTorrent(QString hash) {
if(!h.is_valid()) { if(!h.is_valid()) {
qDebug("Could not pause torrent %s, reason: invalid", hash.toUtf8().data()); qDebug("Could not pause torrent %s, reason: invalid", hash.toUtf8().data());
}else{ }else{
if(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash))) {
// Remove it from queued list if present
if(queuedDownloads->contains(hash))
queuedDownloads->removeAll(hash);
if(queuedUploads->contains(hash))
queuedUploads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
updateDownloadQueue();
updateUploadQueue();
change = true;
} else {
qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data()); qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data());
} }
} }
}
// Create .paused file if necessary // Create .paused file if necessary
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) { 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");
@ -750,15 +763,6 @@ bool bittorrent::pauseTorrent(QString hash) {
// Remove it from TorrentsStartTime hash table // Remove it from TorrentsStartTime hash table
TorrentsStartTime.remove(hash); TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash); TorrentsStartData.remove(hash);
if(queueingEnabled) {
// Remove it from queued list if present
if(queuedDownloads->contains(hash))
queuedDownloads->removeAll(hash);
if(queuedUploads->contains(hash))
queuedUploads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
}
return change; return change;
} }
@ -767,6 +771,7 @@ bool bittorrent::resumeTorrent(QString hash) {
bool success = false; bool success = false;
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if(h.is_valid() && h.is_paused()) { if(h.is_valid() && h.is_paused()) {
if(!(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash)))) {
// Save Addition DateTime // Save Addition DateTime
TorrentsStartData[hash] = h.total_payload_download(); TorrentsStartData[hash] = h.total_payload_download();
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
@ -774,6 +779,7 @@ bool bittorrent::resumeTorrent(QString hash) {
success = true; success = true;
emit resumedTorrent(hash); emit resumedTorrent(hash);
} }
}
// Delete .paused file // Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"); QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
@ -782,6 +788,8 @@ bool bittorrent::resumeTorrent(QString hash) {
torrentsToPauseAfterChecking.removeAt(index); torrentsToPauseAfterChecking.removeAt(index);
success = true; success = true;
} }
updateDownloadQueue();
updateUploadQueue();
return success; return success;
} }

Loading…
Cancel
Save