mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
* Properly catch exceptions from commands called from DownloadFactory.
* The print command was not properly adding the final nul char to the buffer. * Added 'get_d_name' command. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@944 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -230,7 +230,32 @@ DownloadFactory::receive_success() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::for_each(m_commands.begin(), m_commands.end(), rak::bind1st(std::ptr_fun(&rpc::parse_command_d_multiple_std), download));
|
||||
// Save the info-hash just in case the commands decide to delete it.
|
||||
torrent::HashString infohash = download->download()->info_hash();
|
||||
|
||||
try {
|
||||
std::for_each(m_commands.begin(), m_commands.end(), rak::bind1st(std::ptr_fun(&rpc::parse_command_d_multiple_std), download));
|
||||
|
||||
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
|
||||
throw torrent::input_error("The newly created download was removed.");
|
||||
|
||||
} catch (torrent::input_error& e) {
|
||||
std::string msg = "Command on torrent creation failed: " + std::string(e.what());
|
||||
|
||||
if (m_printLog) {
|
||||
m_manager->get_log_important().push_front(msg);
|
||||
m_manager->get_log_complete().push_front(msg);
|
||||
}
|
||||
|
||||
if (m_manager->download_list()->find(infohash) != m_manager->download_list()->end()) {
|
||||
// Should stop it, mark it bad. Perhaps even delete it?
|
||||
download->set_hash_failed(true);
|
||||
download->set_message(msg);
|
||||
// m_manager->download_list()->erase(m_manager->download_list()->find(infohash.data()));
|
||||
}
|
||||
|
||||
return m_slotFinished();
|
||||
}
|
||||
|
||||
// When a download scheduler is implemented, this is handled by the
|
||||
// above insertion into download list.
|
||||
|
||||
@@ -92,6 +92,11 @@ DownloadList::session_save() {
|
||||
std::for_each(begin(), end(), std::bind1st(std::mem_fun(&DownloadStore::save), control->core()->download_store()));
|
||||
}
|
||||
|
||||
DownloadList::iterator
|
||||
DownloadList::find(const torrent::HashString& hash) {
|
||||
return std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&Download::download), std::mem_fun(&torrent::Download::info_hash))));
|
||||
}
|
||||
|
||||
DownloadList::iterator
|
||||
DownloadList::find_hex(const char* hash) {
|
||||
torrent::HashString key;
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include <string>
|
||||
#include <sigc++/slot.h>
|
||||
|
||||
namespace torrent {
|
||||
class HashString;
|
||||
}
|
||||
|
||||
namespace core {
|
||||
|
||||
class Download;
|
||||
@@ -78,6 +82,8 @@ public:
|
||||
|
||||
void session_save();
|
||||
|
||||
iterator find(const torrent::HashString& hash);
|
||||
|
||||
iterator find_hex(const char* hash);
|
||||
Download* find_hex_ptr(const char* hash);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user