mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 23:29:21 +00:00
* Added 'execute.*.bg' commands for non-blocking calls. Always returns 0.
* Added support for prioritizing first/last chunk of files matching specified patterns. Default:
file.prioritize_toc.set=0
file.prioritize_toc.first.set = {*.avi,*.mp4,*.mkv,*.gz}
file.prioritize_toc.last.set = {*.zip}
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1230 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+11
-3
@@ -131,11 +131,19 @@ ExecFile::execute(const char* file, char* const* argv, int flags) {
|
||||
}
|
||||
}
|
||||
|
||||
int status;
|
||||
int wpid = waitpid(childPid, &status, 0);
|
||||
if (flags & flag_background) {
|
||||
if (m_logFd != -1)
|
||||
write(m_logFd, "\n--- Background task ---\n", sizeof("\n--- Background task ---\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (wpid == -1 && rak::error_number::current().value() == rak::error_number::e_intr)
|
||||
int status;
|
||||
int wpid;
|
||||
|
||||
do {
|
||||
wpid = waitpid(childPid, &status, 0);
|
||||
} while (wpid == -1 && rak::error_number::current().value() == rak::error_number::e_intr);
|
||||
|
||||
if (wpid != childPid)
|
||||
throw torrent::internal_error("ExecFile::execute(...) waitpid failed.");
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
static const int flag_expand_tilde = 0x1;
|
||||
static const int flag_throw = 0x2;
|
||||
static const int flag_capture = 0x4;
|
||||
static const int flag_background = 0x8;
|
||||
|
||||
ExecFile() : m_logFd(-1) {}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ object_storage::insert(const char* key_data, uint32_t key_size, const torrent::O
|
||||
case flag_bool_type: object = !!convert_to_value(rawObject); break;
|
||||
case flag_value_type: object = convert_to_value(rawObject); break;
|
||||
case flag_string_type: object = convert_to_string(rawObject); break;
|
||||
case flag_list_type: use_raw = true; break;
|
||||
case flag_function_type: use_raw = true; break;
|
||||
case flag_multi_type: object = torrent::Object::create_map(); break;
|
||||
}
|
||||
@@ -129,6 +130,16 @@ object_storage::set_string(const torrent::raw_string& key, const std::string& ob
|
||||
return itr->second.object = object;
|
||||
}
|
||||
|
||||
const torrent::Object&
|
||||
object_storage::set_list(const torrent::raw_string& key, const torrent::Object::list_type& object) {
|
||||
local_iterator itr = find_local(key);
|
||||
|
||||
if (itr == end(bucket_count()) || (itr->second.flags & mask_type) != flag_list_type)
|
||||
throw torrent::input_error("Key not found or wrong type.");
|
||||
|
||||
return itr->second.object = torrent::Object::create_list_range(object.begin(), object.end());
|
||||
}
|
||||
|
||||
const torrent::Object&
|
||||
object_storage::set_function(const torrent::raw_string& key, const std::string& object) {
|
||||
local_iterator itr = find_local(key);
|
||||
|
||||
@@ -84,8 +84,9 @@ public:
|
||||
static const unsigned int flag_bool_type = 0x2;
|
||||
static const unsigned int flag_value_type = 0x3;
|
||||
static const unsigned int flag_string_type = 0x4;
|
||||
static const unsigned int flag_function_type = 0x5;
|
||||
static const unsigned int flag_multi_type = 0x6;
|
||||
static const unsigned int flag_list_type = 0x5;
|
||||
static const unsigned int flag_function_type = 0x6;
|
||||
static const unsigned int flag_multi_type = 0x7;
|
||||
|
||||
static const unsigned int mask_type = 0xf;
|
||||
|
||||
@@ -122,6 +123,10 @@ public:
|
||||
const torrent::Object& set_c_str_string(const char* str, const std::string& object) { return set_string(torrent::raw_string::from_c_str(str), object); }
|
||||
const torrent::Object& set_str_string(const std::string& str, const std::string& object) { return set_string(torrent::raw_string::from_string(str), object); }
|
||||
|
||||
const torrent::Object& set_list(const torrent::raw_string& key, const torrent::Object::list_type& object);
|
||||
const torrent::Object& set_c_str_list(const char* str, const torrent::Object::list_type& object) { return set_list(torrent::raw_string::from_c_str(str), object); }
|
||||
const torrent::Object& set_str_list(const std::string& str, const torrent::Object::list_type& object) { return set_list(torrent::raw_string::from_string(str), object); }
|
||||
|
||||
// Functions callers:
|
||||
torrent::Object call_function(const torrent::raw_string& key, target_type target, const torrent::Object& object);
|
||||
torrent::Object call_function_str(const std::string& key, target_type target, const torrent::Object& object);
|
||||
|
||||
Reference in New Issue
Block a user