mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-19 07:36:16 +00:00
Changed magnet metadata handling and added 'magnet.path.set'.
This commit is contained in:
@@ -281,6 +281,9 @@ initialize_command_local() {
|
|||||||
|
|
||||||
CMD2_ANY_V ("session.save", [dList](auto, auto) { return dList->session_save(); });
|
CMD2_ANY_V ("session.save", [dList](auto, auto) { return dList->session_save(); });
|
||||||
|
|
||||||
|
CMD2_ANY ("magnet.path", [](auto, auto) { return control->core()->magnet_path(); });
|
||||||
|
CMD2_ANY_STRING_V("magnet.path.set", [](auto, auto& str) { return control->core()->set_magnet_path(str); });
|
||||||
|
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
rpc::LuaEngine* lua_engine = control->lua_engine();
|
rpc::LuaEngine* lua_engine = control->lua_engine();
|
||||||
|
|
||||||
|
|||||||
@@ -254,11 +254,21 @@ DownloadFactory::receive_success() {
|
|||||||
rpc::call_command_value("system.file.split_size"),
|
rpc::call_command_value("system.file.split_size"),
|
||||||
rpc::call_command_string("system.file.split_suffix"));
|
rpc::call_command_string("system.file.split_suffix"));
|
||||||
|
|
||||||
if (!rtorrent->has_key_string("directory"))
|
if (rtorrent->has_key_string("directory")) {
|
||||||
rpc::call_command("d.directory.set", m_variables["directory"], rpc::make_target(download));
|
|
||||||
else
|
|
||||||
rpc::call_command("d.directory_base.set", rtorrent->get_key("directory"), rpc::make_target(download));
|
rpc::call_command("d.directory_base.set", rtorrent->get_key("directory"), rpc::make_target(download));
|
||||||
|
|
||||||
|
} else if (download->download()->info()->is_meta_download()) {
|
||||||
|
auto& metadata_path = control->core()->magnet_path();
|
||||||
|
|
||||||
|
if (!metadata_path.empty())
|
||||||
|
rpc::call_command("d.directory.set", metadata_path, rpc::make_target(download));
|
||||||
|
else
|
||||||
|
rpc::call_command("d.directory.set", session_thread::session_path(), rpc::make_target(download));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
rpc::call_command("d.directory.set", m_variables["directory"], rpc::make_target(download));
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_session && m_variables["tied_to_file"].as_value())
|
if (!m_session && m_variables["tied_to_file"].as_value())
|
||||||
rpc::call_command("d.tied_to_file.set", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
|
rpc::call_command("d.tied_to_file.set", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,16 @@ Manager::retrieve_throttle_value(const torrent::Object::string_type& name, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Manager::set_magnet_path(const std::string& path) {
|
||||||
|
if (path.empty())
|
||||||
|
m_magnet_path.clear();
|
||||||
|
else if (path.back() == '/')
|
||||||
|
m_magnet_path = path;
|
||||||
|
else
|
||||||
|
m_magnet_path = path + '/';
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Manager::cleanup() {
|
Manager::cleanup() {
|
||||||
// Need to disconnect log signals? Not really since we won't receive
|
// Need to disconnect log signals? Not really since we won't receive
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ public:
|
|||||||
|
|
||||||
void set_proxy_address(const std::string& addr);
|
void set_proxy_address(const std::string& addr);
|
||||||
|
|
||||||
|
const std::string& magnet_path();
|
||||||
|
void set_magnet_path(const std::string& path);
|
||||||
|
|
||||||
void shutdown(bool force);
|
void shutdown(bool force);
|
||||||
|
|
||||||
void push_log(const char* msg);
|
void push_log(const char* msg);
|
||||||
@@ -103,11 +106,15 @@ private:
|
|||||||
|
|
||||||
torrent::log_buffer_ptr m_log_important;
|
torrent::log_buffer_ptr m_log_important;
|
||||||
torrent::log_buffer_ptr m_log_complete;
|
torrent::log_buffer_ptr m_log_complete;
|
||||||
|
|
||||||
|
std::string m_magnet_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Meh, cleanup.
|
// Meh, cleanup.
|
||||||
extern void receive_tracker_dump(const std::string& url, const char* data, size_t size);
|
extern void receive_tracker_dump(const std::string& url, const char* data, size_t size);
|
||||||
|
|
||||||
|
inline const std::string& Manager::magnet_path() { return m_magnet_path; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ void cancel_callback(void* target);
|
|||||||
void cancel_callback_and_wait(void* target);
|
void cancel_callback_and_wait(void* target);
|
||||||
|
|
||||||
session::SessionManager* manager();
|
session::SessionManager* manager();
|
||||||
|
std::string session_path();
|
||||||
|
|
||||||
} // namespace torrent::session_thread
|
} // namespace torrent::session_thread
|
||||||
|
|
||||||
|
|||||||
@@ -92,10 +92,12 @@ DownloadStorer::unlink_files(const std::string& session_path) {
|
|||||||
auto torrent_path = base_path;
|
auto torrent_path = base_path;
|
||||||
auto libtorrent_path = base_path + ".libtorrent_resume";
|
auto libtorrent_path = base_path + ".libtorrent_resume";
|
||||||
auto rtorrent_path = base_path + ".rtorrent";
|
auto rtorrent_path = base_path + ".rtorrent";
|
||||||
|
auto metadata_path = base_path + ".meta";
|
||||||
|
|
||||||
::unlink(libtorrent_path.c_str());
|
::unlink(libtorrent_path.c_str());
|
||||||
::unlink(rtorrent_path.c_str());
|
::unlink(rtorrent_path.c_str());
|
||||||
::unlink(torrent_path.c_str());
|
::unlink(torrent_path.c_str());
|
||||||
|
::unlink(metadata_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -82,5 +82,6 @@ void cancel_callback(void* target) { session::ThreadSessio
|
|||||||
void cancel_callback_and_wait(void* target) { session::ThreadSessionInternal::thread_session()->cancel_callback_and_wait(target); }
|
void cancel_callback_and_wait(void* target) { session::ThreadSessionInternal::thread_session()->cancel_callback_and_wait(target); }
|
||||||
|
|
||||||
session::SessionManager* manager() { return session::ThreadSessionInternal::thread_session()->manager(); }
|
session::SessionManager* manager() { return session::ThreadSessionInternal::thread_session()->manager(); }
|
||||||
|
std::string session_path() { return session::ThreadSessionInternal::thread_session()->manager()->path(); }
|
||||||
|
|
||||||
} // namespace session_thread
|
} // namespace session_thread
|
||||||
|
|||||||
Reference in New Issue
Block a user