From a26333bc65f2fb93db260bdd61d79dab7c151f53 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 10 Oct 2007 17:34:52 +0000 Subject: [PATCH] - BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659 REQUIRED) - BUGFIX: AddInPause setting doesn't pause downloads on startup anymore --- Changelog | 1 + TODO | 10 +++---- src/bittorrent.cpp | 63 ++++++++++++++++++++++-------------------- src/bittorrent.h | 8 +++--- src/properties_imp.cpp | 8 ++---- src/src.pro | 2 +- 6 files changed, 45 insertions(+), 47 deletions(-) diff --git a/Changelog b/Changelog index 006cf93f4..b1465c3e6 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ - FEATURE: Added RSS support - FEATURE: Support files prioritizing in a torrent - FEATURE: Brand new search engine plugins system + - FEATURE: Filtered files don't appear on hard disk anymore - FEATURE: Finished torrents are now moved to another tab for seeding - FEATURE: Display more infos about the torrent in its properties - FEATURE: Allow the user to edit torrents' trackers diff --git a/TODO b/TODO index 77929c52d..4574a9604 100644 --- a/TODO +++ b/TODO @@ -56,10 +56,8 @@ - Recheck doc - Translations update (IN PROGRESS) - add qt4-qtconfig as package dependency +- use new sparse mode -rc3->rc4 changelog: -- BUGFIX: Fixed ip filter preferences (couldn't enable it) -- BUGFIX: Fixed compilation problems on FreeBSD (Ok now) -- BUGFIX: Updated INSTALL file -- BUGFIX: Optimized torrent real size calculation -- BUGFIX: Use system default style as a default (instead of Plastique style) \ No newline at end of file +rc4->rc5 changelog: +- BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659) +- BUGFIX: AddInPause setting doesn't pause downloads on startup anymore \ No newline at end of file diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index ad7d1a323..135c95ead 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -82,20 +82,16 @@ bittorrent::~bittorrent() { void bittorrent::preAllocateAllFiles(bool b) { preAllocateAll = b; - if(b) { - // Reload All Torrents - std::vector handles = s->get_torrents(); - unsigned int nbHandles = handles.size(); - for(unsigned int i=0; i handles = s->get_torrents(); + unsigned int nbHandles = handles.size(); + for(unsigned int i=0; iadd_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, false, true); + if(preAllocateAll) { + h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_allocate, true); qDebug(" -> Full allocation mode"); }else{ - h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true, true); - qDebug(" -> Compact allocation mode"); + h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_sparse, true); + qDebug(" -> Sparse allocation mode"); } if(!h.is_valid()) { // No need to keep on, it failed. @@ -485,7 +485,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) { QFile::copy(file, newFile); } // Pause torrent if it was paused last time - if(addInPause || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) { + if(!resumed && (addInPause || QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused"))) { torrentsToPauseAfterChecking << hash; qDebug("Adding a torrent to the torrentsToPauseAfterChecking list"); } @@ -1119,10 +1119,9 @@ void bittorrent::readAlerts() { if(index != -1){ waitingForPause.removeAt(index); } - index = reloadingTorrents.indexOf(hash); - if(index != -1) { - reloadingTorrents.removeAt(index); - reloadTorrent(h); + if(reloadingTorrents.contains(hash)) { + reloadTorrent(h, reloadingTorrents.value(hash)); + reloadingTorrents.remove(hash); } } } @@ -1168,7 +1167,7 @@ QStringList bittorrent::getTorrentsToPauseAfterChecking() const{ // Function to reload the torrent async after the torrent is actually // paused so that we can get fastresume data -void bittorrent::pauseAndReloadTorrent(QTorrentHandle h) { +void bittorrent::pauseAndReloadTorrent(QTorrentHandle h, bool full_alloc) { if(!h.is_valid()) { std::cerr << "/!\\ Error: Invalid handle\n"; return; @@ -1176,14 +1175,14 @@ void bittorrent::pauseAndReloadTorrent(QTorrentHandle h) { // ask to pause the torrent (async) h.pause(); QString hash = h.hash(); - // Add it to reloadingTorrents list so that we now we + // Add it to reloadingTorrents has table so that we now we // we should reload the torrent once we receive the // torrent_paused_alert. pause() is async now... - reloadingTorrents << hash; + reloadingTorrents[hash] = full_alloc; } // Reload a torrent with full allocation mode -void bittorrent::reloadTorrent(const QTorrentHandle &h) { +void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) { qDebug("** Reloading a torrent"); if(!h.is_valid()) { qDebug("/!\\ Error: Invalid handle"); @@ -1214,7 +1213,11 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) { SleeperThread::msleep(1000); ++timeout; } - QTorrentHandle new_h = s->add_torrent(t, saveDir, resumeData, false); + QTorrentHandle new_h; + if(full_alloc) + new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_allocate); + else + new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_sparse); qDebug("Using full allocation mode"); // Connections limit per torrent new_h.set_max_connections(maxConnecsPerTorrent); @@ -1335,7 +1338,7 @@ void bittorrent::applyEncryptionSettings(pe_settings se) { s->set_pe_settings(se); } -// Will fast resume unfinished torrents in +// Will fast resume torrents in // backup directory void bittorrent::resumeUnfinishedTorrents() { qDebug("Resuming unfinished torrents"); @@ -1351,7 +1354,7 @@ void bittorrent::resumeUnfinishedTorrents() { } // Resume downloads foreach(fileName, filePaths) { - addTorrent(fileName, false); + addTorrent(fileName, false, QString(), true); } qDebug("Unfinished torrents resumed"); } diff --git a/src/bittorrent.h b/src/bittorrent.h index 51e175d17..383f3a238 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -48,7 +48,7 @@ class bittorrent : public QObject{ downloadThread *downloader; QString defaultSavePath; QStringList torrentsToPauseAfterChecking; - QStringList reloadingTorrents; + QHash reloadingTorrents; QHash > ETAstats; QHash ETAs; QHash > ratioData; @@ -90,7 +90,7 @@ class bittorrent : public QObject{ bool has_filtered_files(QString hash) const; public slots: - void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString()); + void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); void downloadFromUrl(QString url); void downloadFromURLList(const QStringList& url_list); void deleteTorrent(QString hash, bool permanent = false); @@ -104,7 +104,6 @@ class bittorrent : public QObject{ void enablePeerExchange(); void enableIPFilter(ip_filter filter); void disableIPFilter(); - void pauseAndReloadTorrent(QTorrentHandle h); void resumeUnfinishedTorrents(); void updateETAs(); void saveTorrentSpeedLimits(QString hash); @@ -144,7 +143,8 @@ class bittorrent : public QObject{ void processDownloadedFile(QString, QString); bool loadTrackerFile(QString hash); void saveTrackerFile(QString hash); - void reloadTorrent(const QTorrentHandle &h); // This is protected now, call pauseAndReloadTorrent() instead + void pauseAndReloadTorrent(QTorrentHandle h, bool full_alloc); + void reloadTorrent(const QTorrentHandle &h, bool full_alloc); // This is protected now, call pauseAndReloadTorrent() instead void deleteBigRatios(); signals: diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index feb52a7f9..b322b0e7f 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -693,12 +693,8 @@ bool properties::savePiecesPriorities() { } pieces_file.close(); delete[] priorities; - // If h.has_filtered_pieces() s true, then the torrent - // is already in full allocation mode, no need to - // reload it. - if(hasFilteredFiles && !h.has_filtered_pieces()){ - BTSession->pauseAndReloadTorrent(h); - } + BTSession->loadFilesPriorities(h); + // Emit a signal so that the GUI updates the size emit filteredFilesChanged(hash); has_filtered_files = hasFilteredFiles; return true; diff --git a/src/src.pro b/src/src.pro index ecb86946e..3788a7d70 100644 --- a/src/src.pro +++ b/src/src.pro @@ -30,7 +30,7 @@ contains(DEBUG_MODE, 0){ # For libtorrent stuff # (comment this if you are using libtorrent with debug enabled) -DEFINES += NDEBUG +#DEFINES += NDEBUG # Install