Browse Source

- BUGFIX: Wait for torrent_paused_alert before reloading a torrent for full allocation mode

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
36e87952fa
  1. 6
      TODO
  2. 1
      src/GUI.cpp
  3. 25
      src/bittorrent.cpp
  4. 4
      src/bittorrent.h
  5. 2
      src/properties_imp.cpp
  6. 1
      src/properties_imp.h

6
TODO

@ -45,13 +45,12 @@
- Keep documention up to date - Keep documention up to date
- Windows port (Chris - Peerkoel) - Windows port (Chris - Peerkoel)
- Update to Qt4.3.1 and see if everything is ok - Update to Qt4.3.1 and see if everything is ok
- wait for fastresume data on exit should be in a thread?
* beta5 * beta5
- Translations update (IN PROGRESS) - Translations update (IN PROGRESS)
- make use of finishedChecking alert if hydri applies my patch for this - make use of finishedChecking alert if hydri applies my patch for this
- Clean up delayed progress column sorting code - Clean up delayed progress column sorting code
- Clean up pause after checking code - Clean up pause after checking code
- Fix fast resume problems
- Test rss now that it has been rewritten
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :
- upload/download limit per torrent (Ticket #83) - upload/download limit per torrent (Ticket #83)
- double free or corruption on exit (Ticket #84) FIXED? - double free or corruption on exit (Ticket #84) FIXED?
@ -71,7 +70,8 @@ LANGUAGES UPDATED:
beta4->beta5 changelog: beta4->beta5 changelog:
- FEATURE: Supports Bittorrent FAST extension - FEATURE: Supports Bittorrent FAST extension
- BUGFIX: Wait for torrent_paused_alert before saving fast resume data - BUGFIX: Wait for torrent_paused_alert before saving fast resume data on exit
- BUGFIX: Wait for torrent_paused_alert before reloading a torrent for full allocation mode
- BUFFIG: Fixed overflow causing ratio data to be negative - BUFFIG: Fixed overflow causing ratio data to be negative
- BUGFIX: Fixed progress column delayed sorting (after torrent finished checking) - BUGFIX: Fixed progress column delayed sorting (after torrent finished checking)
- BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert) - BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert)

1
src/GUI.cpp

@ -1229,7 +1229,6 @@ void GUI::showProperties(const QModelIndex &index){
QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString(); QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
torrent_handle h = BTSession->getTorrentHandle(fileHash); torrent_handle h = BTSession->getTorrentHandle(fileHash);
properties *prop = new properties(this, BTSession, h); properties *prop = new properties(this, BTSession, h);
connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle)));
connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString)));
prop->show(); prop->show();
} }

25
src/bittorrent.cpp

@ -948,6 +948,9 @@ void bittorrent::readAlerts(){
torrent_handle h = p->handle; torrent_handle h = p->handle;
if(h.is_valid() && h.is_paused()){ if(h.is_valid() && h.is_paused()){
pausedTorrents << hash; pausedTorrents << hash;
if(reloadingTorrents.indexOf(hash) != -1){
reloadTorrent(h);
}
}else{ }else{
qDebug("Not adding torrent no pausedList, it is invalid or resumed"); qDebug("Not adding torrent no pausedList, it is invalid or resumed");
} }
@ -973,6 +976,22 @@ QList<QPair<QString, QString> > bittorrent::getTrackersErrors(QString hash) cons
return trackersErrors.value(hash, QList<QPair<QString, QString> >()); return trackersErrors.value(hash, QList<QPair<QString, QString> >());
} }
// Function to reload the torrent async after the torrent is actually
// paused so that we can get fastresume data
void bittorrent::pauseAndReloadTorrent(const torrent_handle &h){
if(!h.is_valid()){
std::cerr << "/!\\ Error: Invalid handle\n";
return;
}
// ask to pause the torrent (async)
h.pause();
QString hash = QString(misc::toString(h.info_hash()).c_str());
// Add it to reloadingTorrents list so that we now we
// we should reload the torrent once we receive the
// torrent_paused_alert. pause() is async now...
reloadingTorrents << hash;
}
// Reload a torrent with full allocation mode // Reload a torrent with full allocation mode
void bittorrent::reloadTorrent(const torrent_handle &h){ void bittorrent::reloadTorrent(const torrent_handle &h){
qDebug("** Reloading a torrent"); qDebug("** Reloading a torrent");
@ -998,8 +1017,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
torrentBackup.mkpath(torrentBackup.path()); torrentBackup.mkpath(torrentBackup.path());
} }
// Write fast resume data // Write fast resume data
// Pause download (needed before fast resume writing) // Torrent is already paused
h.pause(); Q_ASSERT(pausedTorrents.indexOf(fileHash) != 1);
// Extracting resume data // Extracting resume data
if (h.has_metadata()){ if (h.has_metadata()){
// get fast resume data // get fast resume data
@ -1041,6 +1060,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
} }
} }
int bittorrent::getListenPort() const{ int bittorrent::getListenPort() const{
return s->listen_port(); return s->listen_port();
} }

4
src/bittorrent.h

@ -49,6 +49,7 @@ class bittorrent : public QObject{
QString defaultSavePath; QString defaultSavePath;
QStringList torrentsToPauseAfterChecking; QStringList torrentsToPauseAfterChecking;
QStringList torrentsUnchecked; QStringList torrentsUnchecked;
QStringList reloadingTorrents;
QHash<QString, QList<long> > ETAstats; QHash<QString, QList<long> > ETAstats;
QHash<QString, long> ETAs; QHash<QString, long> ETAs;
QHash<QString, QPair<size_type,size_type> > ratioData; QHash<QString, QPair<size_type,size_type> > ratioData;
@ -102,7 +103,7 @@ class bittorrent : public QObject{
void enablePeerExchange(); void enablePeerExchange();
void enableIPFilter(ip_filter filter); void enableIPFilter(ip_filter filter);
void disableIPFilter(); void disableIPFilter();
void reloadTorrent(const torrent_handle &h); void pauseAndReloadTorrent(const torrent_handle &h);
void setTorrentFinishedChecking(QString hash); void setTorrentFinishedChecking(QString hash);
void resumeUnfinishedTorrents(); void resumeUnfinishedTorrents();
void updateETAs(); void updateETAs();
@ -133,6 +134,7 @@ 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 torrent_handle &h); // This is protected now, call pauseAndReloadTorrent() instead
signals: signals:
void invalidTorrent(QString path); void invalidTorrent(QString path);

2
src/properties_imp.cpp

@ -606,7 +606,7 @@ void properties::savePiecesPriorities(){
} }
pieces_file.close(); pieces_file.close();
if(hasFilteredFiles && !BTSession->inFullAllocationMode(fileHash)){ if(hasFilteredFiles && !BTSession->inFullAllocationMode(fileHash)){
emit mustHaveFullAllocationMode(h); BTSession->pauseAndReloadTorrent(h);
} }
BTSession->loadFilesPriorities(h); BTSession->loadFilesPriorities(h);
emit filteredFilesChanged(fileHash); emit filteredFilesChanged(fileHash);

1
src/properties_imp.h

@ -73,7 +73,6 @@ class properties : public QDialog, private Ui::properties{
signals: signals:
void filteredFilesChanged(QString fileHash); void filteredFilesChanged(QString fileHash);
void fileSizeChanged(QString fileHash); void fileSizeChanged(QString fileHash);
void mustHaveFullAllocationMode(torrent_handle h);
public: public:
// Constructor // Constructor

Loading…
Cancel
Save