Browse Source

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

adaptive-webui-19844
Christophe Dumez 18 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 @@ @@ -45,13 +45,12 @@
- Keep documention up to date
- Windows port (Chris - Peerkoel)
- Update to Qt4.3.1 and see if everything is ok
- wait for fastresume data on exit should be in a thread?
* beta5
- Translations update (IN PROGRESS)
- make use of finishedChecking alert if hydri applies my patch for this
- Clean up delayed progress column sorting 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 :
- upload/download limit per torrent (Ticket #83)
- double free or corruption on exit (Ticket #84) FIXED?
@ -71,7 +70,8 @@ LANGUAGES UPDATED: @@ -71,7 +70,8 @@ LANGUAGES UPDATED:
beta4->beta5 changelog:
- 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
- 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)

1
src/GUI.cpp

@ -1229,7 +1229,6 @@ void GUI::showProperties(const QModelIndex &index){ @@ -1229,7 +1229,6 @@ void GUI::showProperties(const QModelIndex &index){
QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString();
torrent_handle h = BTSession->getTorrentHandle(fileHash);
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)));
prop->show();
}

25
src/bittorrent.cpp

@ -948,6 +948,9 @@ void bittorrent::readAlerts(){ @@ -948,6 +948,9 @@ void bittorrent::readAlerts(){
torrent_handle h = p->handle;
if(h.is_valid() && h.is_paused()){
pausedTorrents << hash;
if(reloadingTorrents.indexOf(hash) != -1){
reloadTorrent(h);
}
}else{
qDebug("Not adding torrent no pausedList, it is invalid or resumed");
}
@ -973,6 +976,22 @@ QList<QPair<QString, QString> > bittorrent::getTrackersErrors(QString hash) cons @@ -973,6 +976,22 @@ QList<QPair<QString, QString> > bittorrent::getTrackersErrors(QString hash) cons
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
void bittorrent::reloadTorrent(const torrent_handle &h){
qDebug("** Reloading a torrent");
@ -998,8 +1017,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){ @@ -998,8 +1017,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
torrentBackup.mkpath(torrentBackup.path());
}
// Write fast resume data
// Pause download (needed before fast resume writing)
h.pause();
// Torrent is already paused
Q_ASSERT(pausedTorrents.indexOf(fileHash) != 1);
// Extracting resume data
if (h.has_metadata()){
// get fast resume data
@ -1041,6 +1060,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){ @@ -1041,6 +1060,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){
}
}
int bittorrent::getListenPort() const{
return s->listen_port();
}

4
src/bittorrent.h

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

2
src/properties_imp.cpp

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

1
src/properties_imp.h

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

Loading…
Cancel
Save