* Don't show ETA on finished and stopped torrents.

* Added percentage completed to active unfinished torrents.

* Re-enabled different seeding and leeching priorities.

* Make a temporary container in AvailableList::insert(AddressList*)
when doing std::set_differernce. AvailableList's std::vector would
resize and cause invalidated iterators to be used.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@630 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-02-04 19:18:41 +00:00
parent d06ecda46a
commit 68502367ec
17 changed files with 184 additions and 91 deletions
+1 -3
View File
@@ -152,9 +152,7 @@ CurlGet::perform(CURLMsg* msg) {
else
m_signalFailed.emit(curl_easy_strerror(msg->data.result));
if (m_handle != NULL)
throw std::logic_error("CurlGet::perform finished but the object wasn't closed.");
// Do nothing below after emitting the signals.
}
}
+11 -6
View File
@@ -97,14 +97,14 @@ Download::~Download() {
void
Download::start() {
if (is_done()) {
if (is_done())
m_download.set_connection_type(string_to_connection_type(m_variables.get("connection_seed").as_string()));
torrent::download_set_priority(m_download, 2);
} else {
else
m_download.set_connection_type(string_to_connection_type(m_variables.get("connection_leech").as_string()));
torrent::download_set_priority(m_download, 4);
}
// Update the priority to ensure it has the correct
// seeding/unfinished modifiers.
set_priority(priority());
m_download.start();
}
@@ -128,7 +128,12 @@ Download::set_priority(uint32_t p) {
if (p >= 4)
throw torrent::input_error("Priority out of range.");
torrent::download_set_priority(m_download, p * p);
// Seeding torrents get half the priority of unfinished torrents.
if (!is_done())
torrent::download_set_priority(m_download, p * p * 2);
else
torrent::download_set_priority(m_download, p * p);
get_bencode().get_key("rtorrent").insert_key("priority", (int64_t)p);
}
+1
View File
@@ -49,6 +49,7 @@
#include "globals.h"
#include "manager.h"
#include "download.h"
#include "download_factory.h"
namespace core {
+17 -7
View File
@@ -47,6 +47,16 @@
namespace core {
struct download_list_call {
download_list_call(Download* d) : m_download(d) {}
void operator () (const DownloadList::SlotMap::value_type& s) {
s.second(m_download);
}
Download* m_download;
};
DownloadList::iterator
DownloadList::insert(std::istream* str) {
torrent::Download d = torrent::download_add(str);
@@ -54,14 +64,14 @@ DownloadList::insert(std::istream* str) {
iterator itr = Base::insert(end(), new Download(d));
(*itr)->get_download().signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::finished), *itr));
m_slotMapInsert.for_each(*itr);
std::for_each(m_slotMapInsert.begin(), m_slotMapInsert.end(), download_list_call(*itr));
return itr;
}
DownloadList::iterator
DownloadList::erase(iterator itr) {
m_slotMapErase.for_each(*itr);
std::for_each(m_slotMapErase.begin(), m_slotMapErase.end(), download_list_call(*itr));
torrent::download_remove((*itr)->get_download());
delete *itr;
@@ -74,7 +84,7 @@ DownloadList::open(Download* d) {
if (d->get_download().is_open())
return;
m_slotMapOpen.for_each(d);
std::for_each(m_slotMapOpen.begin(), m_slotMapOpen.end(), download_list_call(d));
}
void
@@ -83,7 +93,7 @@ DownloadList::close(Download* d) {
return;
stop(d);
m_slotMapClose.for_each(d);
std::for_each(m_slotMapClose.begin(), m_slotMapClose.end(), download_list_call(d));
}
void
@@ -93,7 +103,7 @@ DownloadList::start(Download* d) {
return;
open(d);
m_slotMapStart.for_each(d);
std::for_each(m_slotMapStart.begin(), m_slotMapStart.end(), download_list_call(d));
}
void
@@ -101,7 +111,7 @@ DownloadList::stop(Download* d) {
if (!d->get_download().is_active())
return;
m_slotMapStop.for_each(d);
std::for_each(m_slotMapStop.begin(), m_slotMapStop.end(), download_list_call(d));
}
void
@@ -113,7 +123,7 @@ DownloadList::clear() {
void
DownloadList::finished(Download* d) {
m_slotMapFinished.for_each(d);
std::for_each(m_slotMapFinished.begin(), m_slotMapFinished.end(), download_list_call(d));
}
}
+19 -17
View File
@@ -39,8 +39,9 @@
#include <iosfwd>
#include <list>
#include "download_slot_map.h"
#include <map>
#include <string>
#include <sigc++/slot.h>
namespace core {
@@ -52,7 +53,8 @@ class Download;
class DownloadList : private std::list<Download*> {
public:
typedef std::list<Download*> Base;
typedef std::list<Download*> Base;
typedef std::map<std::string, sigc::slot1<void, Download*> > SlotMap;
using Base::iterator;
using Base::const_iterator;
@@ -80,28 +82,28 @@ public:
void start(Download* d);
void stop(Download* d);
DownloadSlotMap& slot_map_insert() { return m_slotMapInsert; }
DownloadSlotMap& slot_map_erase() { return m_slotMapErase; }
DownloadSlotMap& slot_map_open() { return m_slotMapOpen; }
DownloadSlotMap& slot_map_close() { return m_slotMapClose; }
DownloadSlotMap& slot_map_start() { return m_slotMapStart; }
DownloadSlotMap& slot_map_stop() { return m_slotMapStop; }
SlotMap& slot_map_insert() { return m_slotMapInsert; }
SlotMap& slot_map_erase() { return m_slotMapErase; }
SlotMap& slot_map_open() { return m_slotMapOpen; }
SlotMap& slot_map_close() { return m_slotMapClose; }
SlotMap& slot_map_start() { return m_slotMapStart; }
SlotMap& slot_map_stop() { return m_slotMapStop; }
DownloadSlotMap& slot_map_finished() { return m_slotMapFinished; }
SlotMap& slot_map_finished() { return m_slotMapFinished; }
private:
void clear();
void finished(Download* d);
DownloadSlotMap m_slotMapInsert;
DownloadSlotMap m_slotMapErase;
DownloadSlotMap m_slotMapOpen;
DownloadSlotMap m_slotMapClose;
DownloadSlotMap m_slotMapStart;
DownloadSlotMap m_slotMapStop;
SlotMap m_slotMapInsert;
SlotMap m_slotMapErase;
SlotMap m_slotMapOpen;
SlotMap m_slotMapClose;
SlotMap m_slotMapStart;
SlotMap m_slotMapStop;
DownloadSlotMap m_slotMapFinished;
SlotMap m_slotMapFinished;
};
}
+1 -1
View File
@@ -65,7 +65,7 @@ DownloadStore::enable(bool lock) {
m_lockfile.set_path(std::string());
if (!m_lockfile.try_lock())
throw torrent::input_error("Could not lock session directory: \"" + m_path + "\".");
throw torrent::input_error("Could not lock session directory: \"" + m_path + "\", held by \"" + m_lockfile.locked_by() + "\".");
}
void
-5
View File
@@ -67,11 +67,6 @@ connect_signal_network_log(Download* d, torrent::Download::SlotString s) {
d->get_download().signal_network_log(s);
}
// static void
// connect_signal_tracker_log(Download* d, torrent::Download::SlotString s) {
// d->get_download().signal_tracker_failed(s);
// }
static void
connect_signal_storage_log(Download* d, torrent::Download::SlotString s) {
d->get_download().signal_storage_error(s);