mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-13 13:42:30 +00:00
* Added "stop_on_ratio" option and display the ratio. Patch by Josef
Drexler, public domain. * Made autogen.sh detect glibtoolize. * Don't resume torrents that are marked as completed yet the initial hash check returns failed chunks. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@704 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/file.h>
|
||||
#include <torrent/path.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/tracker.h>
|
||||
#include <torrent/tracker_list.h>
|
||||
@@ -181,6 +182,40 @@ apply_close_low_diskspace(Control* m, int64_t arg) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
apply_stop_on_ratio(Control* m, const std::string& arg) {
|
||||
int64_t min_Ratio = 0; // first argument: minimum ratio to reach
|
||||
int64_t min_Upload = 0; // second argument: minimum upload amount to reach [optional]
|
||||
int64_t max_Ratio = 0; // third argument: maximum ratio to reach [optional]
|
||||
|
||||
rak::split_iterator_t<std::string> sitr = rak::split_iterator(arg, ',');
|
||||
|
||||
utils::Variable::string_to_value_unit(rak::trim(*sitr).c_str(), &min_Ratio, 0, 1);
|
||||
|
||||
if (++sitr != rak::split_iterator(arg))
|
||||
utils::Variable::string_to_value_unit(rak::trim(*sitr).c_str(), &min_Upload, 0, 1);
|
||||
|
||||
if (++sitr != rak::split_iterator(arg))
|
||||
utils::Variable::string_to_value_unit(rak::trim(*sitr).c_str(), &max_Ratio, 0, 1);
|
||||
|
||||
core::Manager::DListItr itr = m->core()->download_list()->begin();
|
||||
|
||||
while ((itr = std::find_if(itr, m->core()->download_list()->end(),
|
||||
rak::equal(true, std::mem_fun(&core::Download::is_seeding))))
|
||||
!= m->core()->download_list()->end()) {
|
||||
int64_t totalUpload = (*itr)->download()->up_rate()->total();
|
||||
int64_t totalDone = (*itr)->download()->bytes_done();
|
||||
|
||||
if ((totalUpload >= min_Upload && totalUpload * 100 >= totalDone * min_Ratio) ||
|
||||
(max_Ratio > 0 && totalUpload * 100 > totalDone * max_Ratio)) {
|
||||
if ((*itr)->variable()->get_value("ignore_ratio") <= 0)
|
||||
m->core()->download_list()->stop(*itr);
|
||||
}
|
||||
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
apply_encoding_list(__UNUSED Control* m, const std::string& arg) {
|
||||
torrent::encoding_list()->push_back(arg);
|
||||
@@ -432,7 +467,8 @@ initialize_option_handler(Control* c) {
|
||||
variables->insert("stop_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_stop_untied, c)));
|
||||
variables->insert("close_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_close_untied, c)));
|
||||
variables->insert("remove_untied", new utils::VariableVoidSlot(rak::bind_ptr_fn(&apply_remove_untied, c)));
|
||||
variables->insert("close_low_diskspace", new utils::VariableValueSlot(rak::value_fn(int64_t()), rak::bind_ptr_fn(&apply_close_low_diskspace, c)));
|
||||
variables->insert("close_low_diskspace", new utils::VariableValueSlot(rak::value_fn(int64_t()), rak::bind_ptr_fn(&apply_close_low_diskspace, c)));
|
||||
variables->insert("stop_on_ratio", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_stop_on_ratio, c)));
|
||||
|
||||
variables->insert("enable_trackers", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_enable_trackers, c)));
|
||||
variables->insert("encoding_list", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_encoding_list, c)));
|
||||
|
||||
Reference in New Issue
Block a user