mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 22:59:21 +00:00
* Cleanup of command handling.
* Added 'd.timestamp.finished' that is set when a downloading torrent completes. For torrents that only seed it remains '0'.
* Added 'elapsed.{less,greater}' for checking the time elapsed since a time is less/greater, and it also returns false in all cases where the time is '0'.
* Fixed a bug that would cause hash checking to block exessively in some cases.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1233 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -205,7 +205,10 @@ object_storage::erase_multi_key(const torrent::raw_string& key, const std::strin
|
||||
}
|
||||
|
||||
void
|
||||
object_storage::set_multi_key(const torrent::raw_string& key, const std::string& cmd_key, const std::string& object) {
|
||||
object_storage::set_multi_key_obj(const torrent::raw_string& key, const std::string& cmd_key, const torrent::Object& object) {
|
||||
if (!object.is_string() && !object.is_dict_key())
|
||||
throw torrent::input_error("Object is wrong type.");
|
||||
|
||||
local_iterator itr = find_local(key);
|
||||
|
||||
if (itr == end(0) || (itr->second.flags & mask_type) != flag_multi_type)
|
||||
|
||||
@@ -150,11 +150,14 @@ public:
|
||||
// Multi-command function:
|
||||
bool has_multi_key(const torrent::raw_string& key, const std::string& cmd_key);
|
||||
void erase_multi_key(const torrent::raw_string& key, const std::string& cmd_key);
|
||||
void set_multi_key(const torrent::raw_string& key, const std::string& cmd_key, const std::string& object);
|
||||
void set_multi_key_obj(const torrent::raw_string& key, const std::string& cmd_key, const torrent::Object& object);
|
||||
|
||||
void set_multi_key(const torrent::raw_string& key, const std::string& cmd_key, const std::string& object) { set_multi_key_obj(key, cmd_key, object); }
|
||||
|
||||
bool has_str_multi_key(const std::string& key, const std::string& cmd_key);
|
||||
void erase_str_multi_key(const std::string& key, const std::string& cmd_key);
|
||||
void set_str_multi_key(const std::string& key, const std::string& cmd_key, const std::string& object);
|
||||
void set_str_multi_key_obj(const std::string& key, const std::string& cmd_key, const torrent::Object& object);
|
||||
|
||||
torrent::Object::list_type rlookup_list(const std::string& cmd_key);
|
||||
torrent::Object rlookup_obj_list(const std::string& cmd_key) { return torrent::Object::from_list(rlookup_list(cmd_key)); }
|
||||
@@ -241,7 +244,12 @@ object_storage::erase_str_multi_key(const std::string& key, const std::string& c
|
||||
|
||||
inline void
|
||||
object_storage::set_str_multi_key(const std::string& key, const std::string& cmd_key, const std::string& object) {
|
||||
return set_multi_key(torrent::raw_string::from_string(key), cmd_key, object);
|
||||
return set_multi_key_obj(torrent::raw_string::from_string(key), cmd_key, object);
|
||||
}
|
||||
|
||||
inline void
|
||||
object_storage::set_str_multi_key_obj(const std::string& key, const std::string& cmd_key, const torrent::Object& object) {
|
||||
return set_multi_key_obj(torrent::raw_string::from_string(key), cmd_key, object);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -295,10 +295,18 @@ command_function_call_object(const torrent::Object& cmd, target_type target, con
|
||||
}
|
||||
|
||||
} else {
|
||||
torrent::Object tmp_cmd = cmd;
|
||||
|
||||
rpc::parse_command_execute(target, &tmp_cmd);
|
||||
result = rpc::commands.call_command(tmp_cmd.as_dict_key().c_str(), tmp_cmd.as_dict_obj());
|
||||
torrent::Object tmp_command = cmd;
|
||||
|
||||
// Unquote the root function object so 'parse_command_execute'
|
||||
// doesn't end up calling it.
|
||||
//
|
||||
// TODO: Only call this if mask_function is set?
|
||||
uint32_t flags = tmp_command.flags() & torrent::Object::mask_function;
|
||||
tmp_command.unset_flags(torrent::Object::mask_function);
|
||||
tmp_command.set_flags((flags >> 1) & torrent::Object::mask_function);
|
||||
|
||||
rpc::parse_command_execute(target, &tmp_command);
|
||||
rpc::commands.call_command(tmp_command.as_dict_key().c_str(), tmp_command.as_dict_obj(), target);
|
||||
}
|
||||
|
||||
rpc::command_base::pop_stack(&stack, last_stack);
|
||||
@@ -324,6 +332,23 @@ command_function_multi_call(const torrent::Object::map_type& cmd, target_type ta
|
||||
|
||||
try {
|
||||
for (torrent::Object::map_const_iterator itr = cmd.begin(), last = cmd.end(); itr != last; itr++) {
|
||||
if (itr->second.is_dict_key()) {
|
||||
// This can/should be optimized...
|
||||
torrent::Object tmp_command = itr->second;
|
||||
|
||||
// Unquote the root function object so 'parse_command_execute'
|
||||
// doesn't end up calling it.
|
||||
//
|
||||
// TODO: Only call this if mask_function is set?
|
||||
uint32_t flags = tmp_command.flags() & torrent::Object::mask_function;
|
||||
tmp_command.unset_flags(torrent::Object::mask_function);
|
||||
tmp_command.set_flags((flags >> 1) & torrent::Object::mask_function);
|
||||
|
||||
rpc::parse_command_execute(target, &tmp_command);
|
||||
rpc::commands.call_command(tmp_command.as_dict_key().c_str(), tmp_command.as_dict_obj(), target);
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string& cmd_str = itr->second.as_string();
|
||||
parse_command_multiple(target, cmd_str.c_str(), cmd_str.c_str() + cmd_str.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user