Browse Source

- Fixed remembering of paused torrents cleanly

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
cd260198f9
  1. 8
      src/bittorrent.cpp
  2. 4
      src/qtorrenthandle.cpp
  3. 2
      src/qtorrenthandle.h

8
src/bittorrent.cpp

@ -456,11 +456,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo @@ -456,11 +456,7 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
p.duplicate_is_error = false; // Already checked
p.auto_managed = false; // Because it is added in paused state
// Adding torrent to bittorrent session
h = s->add_torrent(p);
// XXX: Workaround for http://code.rasterbar.com/libtorrent/ticket/454
h.pause(false);
//Q_ASSERT(!h.is_auto_managed());
//Q_ASSERT(h.is_paused());
h = QTorrentHandle(s->add_torrent(p));
// Check if it worked
if(!h.is_valid()) {
// No need to keep on, it failed.
@ -806,7 +802,7 @@ void bittorrent::saveFastResumeData() { @@ -806,7 +802,7 @@ void bittorrent::saveFastResumeData() {
for(unsigned int i=0; i<torrents.size(); ++i) {
QTorrentHandle h(torrents[i]);
if(!h.is_valid()) continue;
if(h.is_paused()) continue;
//if(h.is_paused()) continue;
if (!h.has_metadata()) continue;
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
h.save_resume_data();

4
src/qtorrenthandle.cpp

@ -315,12 +315,12 @@ void QTorrentHandle::set_upload_limit(int limit) { @@ -315,12 +315,12 @@ void QTorrentHandle::set_upload_limit(int limit) {
h.set_upload_limit(limit);
}
void QTorrentHandle::pause(bool create_file) {
void QTorrentHandle::pause() {
Q_ASSERT(h.is_valid());
h.auto_managed(false);
h.pause();
// Create .paused file if necessary
if(create_file && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) {
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) {
QFile paused_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused");
paused_file.open(QIODevice::WriteOnly | QIODevice::Text);
paused_file.close();

2
src/qtorrenthandle.h

@ -103,7 +103,7 @@ class QTorrentHandle { @@ -103,7 +103,7 @@ class QTorrentHandle {
void set_download_limit(int limit);
void set_upload_limit(int limit);
void pause(bool create_file=true);
void pause();
void resume();
void remove_url_seed(QString seed);
void add_url_seed(QString seed);

Loading…
Cancel
Save