Browse Source

- Wait for torrent_paused_alert before saving fast resume data

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
f9c357b52d
  1. 3
      TODO
  2. 2
      src/GUI.cpp
  3. 25
      src/bittorrent.cpp
  4. 2
      src/bittorrent.h

3
TODO

@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
- Clean up delayed progress column sorting code
- Clean up pause after checking code
- Test rss now that it has been rewritten
- Wait for torrent_paused_alert before saving fast resume data
- Fix number of finishedChecking torrents
- Wait for some bug fixes in libtorrent :
- upload/download limit per torrent (Ticket #83)
- double free or corruption on exit (Ticket #84) FIXED?
@ -68,6 +68,7 @@ LANGUAGES UPDATED: @@ -68,6 +68,7 @@ LANGUAGES UPDATED:
- Polish *BETA5*
beta4->beta5 changelog:
- BUGFIX: Wait for torrent_paused_alert before saving fast resume data
- BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert)
- I18N: Updated Italian translation
- COSMETIC: Changed the way progress bars are rendered

2
src/GUI.cpp

@ -211,7 +211,6 @@ GUI::~GUI(){ @@ -211,7 +211,6 @@ GUI::~GUI(){
delete finishedTorrentTab;
delete checkConnect;
delete refresher;
delete BTSession;
if(systrayIntegration){
delete myTrayIcon;
delete myTrayIconMenu;
@ -228,6 +227,7 @@ GUI::~GUI(){ @@ -228,6 +227,7 @@ GUI::~GUI(){
delete switchDownShortcut;
delete switchUpShortcut;
delete switchRSSShortcut;
delete BTSession;
}
void GUI::on_actionWebsite_triggered(){

25
src/bittorrent.cpp

@ -188,6 +188,10 @@ void bittorrent::deleteTorrent(QString hash, bool permanent){ @@ -188,6 +188,10 @@ void bittorrent::deleteTorrent(QString hash, bool permanent){
int index = fullAllocationModeList.indexOf(hash);
if(index != -1)
fullAllocationModeList.removeAt(index);
// Remove it from pausedTorrents list
index = pausedTorrents.indexOf(hash);
if(index != -1)
pausedTorrents.removeAt(index);
if(permanent){
// Remove from Hard drive
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
@ -242,6 +246,10 @@ bool bittorrent::resumeTorrent(QString hash){ @@ -242,6 +246,10 @@ bool bittorrent::resumeTorrent(QString hash){
torrentsToPauseAfterChecking.removeAt(index);
success = true;
}
// Remove it from pausedTorrents list
index = pausedTorrents.indexOf(hash);
if(index != -1)
pausedTorrents.removeAt(index);
return success;
}
@ -646,6 +654,10 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash){ @@ -646,6 +654,10 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash){
ratio_file.close();
}
bool bittorrent::receivedPausedAlert(QString hash) const{
return (pausedTorrents.indexOf(hash) != -1);
}
// Save fastresume data for all torrents
// and remove them from the session
void bittorrent::saveFastResumeAndRatioData(){
@ -667,9 +679,13 @@ void bittorrent::saveFastResumeAndRatioData(){ @@ -667,9 +679,13 @@ void bittorrent::saveFastResumeAndRatioData(){
}
// Pause download (needed before fast resume writing)
h.pause();
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
while(!receivedPausedAlert(fileHash)){
SleeperThread::msleep(500);
readAlerts();
}
// Extracting resume data
if (h.has_metadata()){
QString fileHash = QString(misc::toString(h.info_hash()).c_str());
if(QFile::exists(torrentBackup.path()+QDir::separator()+fileHash+".torrent")){
// Remove old .fastresume data in case it exists
QFile::remove(torrentBackup.path()+QDir::separator()+fileHash + ".fastresume");
@ -908,10 +924,17 @@ void bittorrent::readAlerts(){ @@ -908,10 +924,17 @@ void bittorrent::readAlerts(){
emit trackerAuthenticationRequired(p->handle);
}
}
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())){
QString hash = QString(misc::toString(p->handle.info_hash()).c_str());
qDebug("Received torrent_paused_alert for %s", (const char*)hash.toUtf8());
Q_ASSERT(!pausedTorrents.contains(hash));
pausedTorrents << hash;
}
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())){
emit peerBlocked(QString(p->ip.to_string().c_str()));
}
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())){
qDebug("/!\\ Fast resume failed for %s, reason: %s", p->handle.name().c_str(), p->msg().c_str());
emit fastResumeDataRejected(QString(p->handle.name().c_str()));
}
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())){

2
src/bittorrent.h

@ -56,6 +56,7 @@ class bittorrent : public QObject{ @@ -56,6 +56,7 @@ class bittorrent : public QObject{
QList<QString> fullAllocationModeList;
QHash<QString, QList<QPair<QString, QString> > > trackersErrors;
deleteThread *deleter;
QList<QString> pausedTorrents;
protected:
QString getSavePath(QString hash);
@ -82,6 +83,7 @@ class bittorrent : public QObject{ @@ -82,6 +83,7 @@ class bittorrent : public QObject{
float getRealRatio(QString hash) const;
session* getSession() const;
QList<QPair<QString, QString> > getTrackersErrors(QString hash) const;
bool receivedPausedAlert(QString hash) const;
public slots:
void addTorrent(QString path, bool fromScanDir = false, bool onStartup = false, QString from_url = QString());

Loading…
Cancel
Save