Browse Source

- Remember paused torrents on startup

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
71e3061c18
  1. 8
      src/bittorrent.cpp
  2. 12
      src/qtorrenthandle.cpp
  3. 2
      src/qtorrenthandle.h
  4. 6
      src/src.pro

8
src/bittorrent.cpp

@ -454,9 +454,13 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
// Start in pause // Start in pause
p.paused = true; p.paused = true;
p.duplicate_is_error = false; // Already checked p.duplicate_is_error = false; // Already checked
p.auto_managed = true; p.auto_managed = false; // Because it is added in paused state
// Adding torrent to bittorrent session // Adding torrent to bittorrent session
h = s->add_torrent(p); 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());
// Check if it worked // Check if it worked
if(!h.is_valid()) { if(!h.is_valid()) {
// No need to keep on, it failed. // No need to keep on, it failed.
@ -1118,7 +1122,7 @@ void bittorrent::readAlerts() {
if(h.is_valid()){ if(h.is_valid()){
emit finishedTorrent(h); emit finishedTorrent(h);
QString hash = h.hash(); QString hash = h.hash();
// Create .paused file if necessary // Create .finished file if necessary
QFile finished_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished"); QFile finished_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished");
finished_file.open(QIODevice::WriteOnly | QIODevice::Text); finished_file.open(QIODevice::WriteOnly | QIODevice::Text);
finished_file.close(); finished_file.close();

12
src/qtorrenthandle.cpp

@ -315,16 +315,26 @@ void QTorrentHandle::set_upload_limit(int limit) {
h.set_upload_limit(limit); h.set_upload_limit(limit);
} }
void QTorrentHandle::pause() { void QTorrentHandle::pause(bool create_file) {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.auto_managed(false); h.auto_managed(false);
h.pause(); h.pause();
// Create .paused file if necessary
if(create_file && !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();
}
} }
void QTorrentHandle::resume() { void QTorrentHandle::resume() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
h.auto_managed(true); h.auto_managed(true);
h.resume(); h.resume();
// Delete .paused file if necessary
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused")) {
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash()+".paused");
}
} }
void QTorrentHandle::remove_url_seed(QString seed) { void QTorrentHandle::remove_url_seed(QString seed) {

2
src/qtorrenthandle.h

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

6
src/src.pro

@ -92,10 +92,8 @@ DEFINES += NDEBUG
icon128 \ icon128 \
icon192 icon192
} }
QMAKE_CXXFLAGS_RELEASE += -fwrapv \ QMAKE_CXXFLAGS_RELEASE += -fwrapv
-O2 QMAKE_CXXFLAGS_DEBUG += -fwrapv
QMAKE_CXXFLAGS_DEBUG += -fwrapv \
-O0
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += "libtorrent-rasterbar libcurl" PKGCONFIG += "libtorrent-rasterbar libcurl"

Loading…
Cancel
Save