Browse Source

- BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659 REQUIRED)

- BUGFIX: AddInPause setting doesn't pause downloads on startup anymore
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
a26333bc65
  1. 1
      Changelog
  2. 10
      TODO
  3. 47
      src/bittorrent.cpp
  4. 8
      src/bittorrent.h
  5. 8
      src/properties_imp.cpp
  6. 2
      src/src.pro

1
Changelog

@ -6,6 +6,7 @@
- FEATURE: Added RSS support - FEATURE: Added RSS support
- FEATURE: Support files prioritizing in a torrent - FEATURE: Support files prioritizing in a torrent
- FEATURE: Brand new search engine plugins system - 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: Finished torrents are now moved to another tab for seeding
- FEATURE: Display more infos about the torrent in its properties - FEATURE: Display more infos about the torrent in its properties
- FEATURE: Allow the user to edit torrents' trackers - FEATURE: Allow the user to edit torrents' trackers

10
TODO

@ -56,10 +56,8 @@
- Recheck doc - Recheck doc
- Translations update (IN PROGRESS) - Translations update (IN PROGRESS)
- add qt4-qtconfig as package dependency - add qt4-qtconfig as package dependency
- use new sparse mode
rc3->rc4 changelog: rc4->rc5 changelog:
- BUGFIX: Fixed ip filter preferences (couldn't enable it) - BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659)
- BUGFIX: Fixed compilation problems on FreeBSD (Ok now) - BUGFIX: AddInPause setting doesn't pause downloads on startup anymore
- BUGFIX: Updated INSTALL file
- BUGFIX: Optimized torrent real size calculation
- BUGFIX: Use system default style as a default (instead of Plastique style)

47
src/bittorrent.cpp

@ -82,7 +82,6 @@ bittorrent::~bittorrent() {
void bittorrent::preAllocateAllFiles(bool b) { void bittorrent::preAllocateAllFiles(bool b) {
preAllocateAll = b; preAllocateAll = b;
if(b) {
// Reload All Torrents // Reload All Torrents
std::vector<torrent_handle> handles = s->get_torrents(); std::vector<torrent_handle> handles = s->get_torrents();
unsigned int nbHandles = handles.size(); unsigned int nbHandles = handles.size();
@ -92,10 +91,7 @@ void bittorrent::preAllocateAllFiles(bool b) {
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
continue; continue;
} }
QString hash = h.hash(); pauseAndReloadTorrent(h, b);
if(has_filtered_files(hash)) continue;
reloadTorrent(h);
}
} }
} }
@ -228,6 +224,10 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
ETAs.remove(hash); ETAs.remove(hash);
// Remove tracker errors // Remove tracker errors
trackersErrors.remove(hash); trackersErrors.remove(hash);
// Remove from reloadingTorrents if reloading
if(reloadingTorrents.contains(hash)) {
reloadingTorrents.remove(hash);
}
// Remove it from ratio table // Remove it from ratio table
ratioData.remove(hash); ratioData.remove(hash);
int index = finishedTorrents.indexOf(hash); int index = finishedTorrents.indexOf(hash);
@ -373,7 +373,7 @@ void bittorrent::loadWebSeeds(QString hash) {
} }
// Add a torrent to the bittorrent session // Add a torrent to the bittorrent session
void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) { void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
QTorrentHandle h; QTorrentHandle h;
entry resume_data; entry resume_data;
bool fastResume=false; bool fastResume=false;
@ -443,12 +443,12 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url) {
} }
QString savePath = getSavePath(hash); QString savePath = getSavePath(hash);
// Adding files to bittorrent session // Adding files to bittorrent session
if(has_filtered_files(hash) || preAllocateAll) { if(preAllocateAll) {
h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, false, true); h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_allocate, true);
qDebug(" -> Full allocation mode"); qDebug(" -> Full allocation mode");
}else{ }else{
h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, true, true); h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_sparse, true);
qDebug(" -> Compact allocation mode"); qDebug(" -> Sparse allocation mode");
} }
if(!h.is_valid()) { if(!h.is_valid()) {
// No need to keep on, it failed. // 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); QFile::copy(file, newFile);
} }
// Pause torrent if it was paused last time // 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; torrentsToPauseAfterChecking << hash;
qDebug("Adding a torrent to the torrentsToPauseAfterChecking list"); qDebug("Adding a torrent to the torrentsToPauseAfterChecking list");
} }
@ -1119,10 +1119,9 @@ void bittorrent::readAlerts() {
if(index != -1){ if(index != -1){
waitingForPause.removeAt(index); waitingForPause.removeAt(index);
} }
index = reloadingTorrents.indexOf(hash); if(reloadingTorrents.contains(hash)) {
if(index != -1) { reloadTorrent(h, reloadingTorrents.value(hash));
reloadingTorrents.removeAt(index); reloadingTorrents.remove(hash);
reloadTorrent(h);
} }
} }
} }
@ -1168,7 +1167,7 @@ QStringList bittorrent::getTorrentsToPauseAfterChecking() const{
// Function to reload the torrent async after the torrent is actually // Function to reload the torrent async after the torrent is actually
// paused so that we can get fastresume data // 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()) { if(!h.is_valid()) {
std::cerr << "/!\\ Error: Invalid handle\n"; std::cerr << "/!\\ Error: Invalid handle\n";
return; return;
@ -1176,14 +1175,14 @@ void bittorrent::pauseAndReloadTorrent(QTorrentHandle h) {
// ask to pause the torrent (async) // ask to pause the torrent (async)
h.pause(); h.pause();
QString hash = h.hash(); 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 // we should reload the torrent once we receive the
// torrent_paused_alert. pause() is async now... // torrent_paused_alert. pause() is async now...
reloadingTorrents << hash; reloadingTorrents[hash] = full_alloc;
} }
// Reload a torrent with full allocation mode // 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"); qDebug("** Reloading a torrent");
if(!h.is_valid()) { if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle"); qDebug("/!\\ Error: Invalid handle");
@ -1214,7 +1213,11 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) {
SleeperThread::msleep(1000); SleeperThread::msleep(1000);
++timeout; ++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"); qDebug("Using full allocation mode");
// Connections limit per torrent // Connections limit per torrent
new_h.set_max_connections(maxConnecsPerTorrent); new_h.set_max_connections(maxConnecsPerTorrent);
@ -1335,7 +1338,7 @@ void bittorrent::applyEncryptionSettings(pe_settings se) {
s->set_pe_settings(se); s->set_pe_settings(se);
} }
// Will fast resume unfinished torrents in // Will fast resume torrents in
// backup directory // backup directory
void bittorrent::resumeUnfinishedTorrents() { void bittorrent::resumeUnfinishedTorrents() {
qDebug("Resuming unfinished torrents"); qDebug("Resuming unfinished torrents");
@ -1351,7 +1354,7 @@ void bittorrent::resumeUnfinishedTorrents() {
} }
// Resume downloads // Resume downloads
foreach(fileName, filePaths) { foreach(fileName, filePaths) {
addTorrent(fileName, false); addTorrent(fileName, false, QString(), true);
} }
qDebug("Unfinished torrents resumed"); qDebug("Unfinished torrents resumed");
} }

8
src/bittorrent.h

@ -48,7 +48,7 @@ class bittorrent : public QObject{
downloadThread *downloader; downloadThread *downloader;
QString defaultSavePath; QString defaultSavePath;
QStringList torrentsToPauseAfterChecking; QStringList torrentsToPauseAfterChecking;
QStringList reloadingTorrents; QHash<QString, bool> reloadingTorrents;
QHash<QString, QList<qlonglong> > ETAstats; QHash<QString, QList<qlonglong> > ETAstats;
QHash<QString, qlonglong> ETAs; QHash<QString, qlonglong> ETAs;
QHash<QString, QPair<size_type,size_type> > ratioData; QHash<QString, QPair<size_type,size_type> > ratioData;
@ -90,7 +90,7 @@ class bittorrent : public QObject{
bool has_filtered_files(QString hash) const; bool has_filtered_files(QString hash) const;
public slots: 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 downloadFromUrl(QString url);
void downloadFromURLList(const QStringList& url_list); void downloadFromURLList(const QStringList& url_list);
void deleteTorrent(QString hash, bool permanent = false); void deleteTorrent(QString hash, bool permanent = false);
@ -104,7 +104,6 @@ class bittorrent : public QObject{
void enablePeerExchange(); void enablePeerExchange();
void enableIPFilter(ip_filter filter); void enableIPFilter(ip_filter filter);
void disableIPFilter(); void disableIPFilter();
void pauseAndReloadTorrent(QTorrentHandle h);
void resumeUnfinishedTorrents(); void resumeUnfinishedTorrents();
void updateETAs(); void updateETAs();
void saveTorrentSpeedLimits(QString hash); void saveTorrentSpeedLimits(QString hash);
@ -144,7 +143,8 @@ class bittorrent : public QObject{
void processDownloadedFile(QString, QString); void processDownloadedFile(QString, QString);
bool loadTrackerFile(QString hash); bool loadTrackerFile(QString hash);
void saveTrackerFile(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(); void deleteBigRatios();
signals: signals:

8
src/properties_imp.cpp

@ -693,12 +693,8 @@ bool properties::savePiecesPriorities() {
} }
pieces_file.close(); pieces_file.close();
delete[] priorities; delete[] priorities;
// If h.has_filtered_pieces() s true, then the torrent BTSession->loadFilesPriorities(h);
// is already in full allocation mode, no need to // Emit a signal so that the GUI updates the size
// reload it.
if(hasFilteredFiles && !h.has_filtered_pieces()){
BTSession->pauseAndReloadTorrent(h);
}
emit filteredFilesChanged(hash); emit filteredFilesChanged(hash);
has_filtered_files = hasFilteredFiles; has_filtered_files = hasFilteredFiles;
return true; return true;

2
src/src.pro

@ -30,7 +30,7 @@ contains(DEBUG_MODE, 0){
# For libtorrent stuff # For libtorrent stuff
# (comment this if you are using libtorrent with debug enabled) # (comment this if you are using libtorrent with debug enabled)
DEFINES += NDEBUG #DEFINES += NDEBUG
# Install # Install

Loading…
Cancel
Save