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. 44
      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) {

44
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,7 +738,20 @@ 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{
qDebug("Could not pause torrent %s, reason: already paused", hash.toUtf8().data()); 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());
}
} }
} }
// Create .paused file if necessary // Create .paused file if necessary
@ -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,12 +771,14 @@ 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()) {
// Save Addition DateTime if(!(queueingEnabled && (isDownloadQueued(hash)||isUploadQueued(hash)))) {
TorrentsStartData[hash] = h.total_payload_download(); // Save Addition DateTime
TorrentsStartTime[hash] = QDateTime::currentDateTime(); TorrentsStartData[hash] = h.total_payload_download();
h.resume(); TorrentsStartTime[hash] = QDateTime::currentDateTime();
success = true; h.resume();
emit resumedTorrent(hash); success = true;
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"))
@ -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