- Sync with stable branch (lot of bug fixing)

This commit is contained in:
Christophe Dumez 2008-09-13 18:53:58 +00:00
parent 0e7c16901c
commit 95ecaec11e
9 changed files with 121 additions and 120 deletions

View file

@ -574,8 +574,6 @@ bool bittorrent::isPaused(QString hash) const{
qDebug("/!\\ Error: Invalid handle");
return true;
}
if(torrentsToPauseAfterChecking.contains(hash))
return true;
return h.is_paused();
}
@ -833,11 +831,6 @@ bool bittorrent::resumeTorrent(QString hash) {
// Delete .paused file
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused");
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
change = true;
}
if(queueingEnabled) {
updateDownloadQueue();
updateUploadQueue();
@ -892,7 +885,7 @@ void bittorrent::loadWebSeeds(QString hash) {
}
// Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool) {
QTorrentHandle h;
entry resume_data;
bool fastResume=false;
@ -1005,18 +998,15 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
// Copy it to torrentBackup directory
QFile::copy(file, newFile);
}
// Pause torrent if it was paused last time
if((!resumed && addInPause) || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
}
// Incremental download
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
qDebug("Incremental download enabled for %s", t->name().c_str());
h.set_sequenced_download_threshold(1);
}
// Start torrent because it was added in paused state
h.resume();
if(!addInPause && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
// Start torrent because it was added in paused state
h.resume();
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash;
if(queueingEnabled) {
@ -1353,6 +1343,14 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash) {
ratioData[hash] = downUp;
}
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();
}
float bittorrent::getRealRatio(QString hash) const{
QPair<size_type,size_type> downUpInfo = ratioData.value(hash, QPair<size_type,size_type>(0,0));
size_type download = downUpInfo.first;
@ -1813,20 +1811,14 @@ void bittorrent::readAlerts() {
if(h.is_valid()){
QString hash = h.hash();
qDebug("%s have just finished checking", hash.toUtf8().data());
int index = torrentsToPauseAfterChecking.indexOf(hash);
if(index != -1) {
torrentsToPauseAfterChecking.removeAt(index);
// Pause torrent
pauseTorrent(hash);
qDebug("%s was paused after checking", hash.toUtf8().data());
} else {
if(!h.is_paused()) {
// Save Addition DateTime
if(calculateETA) {
TorrentsStartTime[hash] = QDateTime::currentDateTime();
TorrentsStartData[hash] = h.total_payload_download();
}
}
emit torrentFinishedChecking(hash);
}
//emit torrentFinishedChecking(hash);
}
}
a = s->pop_alert();
@ -1837,10 +1829,6 @@ QHash<QString, QString> bittorrent::getTrackersErrors(QString hash) const{
return trackersErrors.value(hash, QHash<QString, QString>());
}
QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
return torrentsToPauseAfterChecking;
}
// Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) {
qDebug("** Reloading a torrent");