Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing different handling to metadata files. #1079

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/command_local.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ initialize_command_local() {

CMD2_ANY_V ("session.save", std::bind(&core::DownloadList::session_save, dList));

CMD2_ANY ("metadir.path", std::bind(&core::DownloadStore::metadir_path, dStore));
CMD2_ANY_STRING_V("metadir.path.set", std::bind(&core::DownloadStore::set_metadir_path, dStore, std::placeholders::_2));

#define CMD2_EXECUTE(key, flags) \
CMD2_ANY(key, std::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::placeholders::_2, flags));

Expand Down
12 changes: 9 additions & 3 deletions src/core/download_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,15 @@ DownloadFactory::receive_success() {
rpc::call_command_value("system.file.split_size"),
rpc::call_command_string("system.file.split_suffix"));

if (!rtorrent->has_key_string("directory"))
rpc::call_command("d.directory.set", m_variables["directory"], rpc::make_target(download));
else
if (!rtorrent->has_key_string("directory")) {
if (download->download()->info()->is_meta_download()) {
if(!rpc::call_command("metadir.path").is_string_empty())
rpc::call_command("d.directory.set", rpc::call_command("metadir.path"), rpc::make_target(download));
else
rpc::call_command("d.directory.set", rpc::call_command("session.path"), rpc::make_target(download));
} else
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));

if (!m_session && m_variables["tied_to_file"].as_value())
Expand Down
8 changes: 8 additions & 0 deletions src/core/download_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ DownloadStore::disable() {
m_lockfile.unlock();
}

void
DownloadStore::set_metadir_path(const std::string& path) {
if (!path.empty() && *path.rbegin() != '/')
m_metadir_path = rak::path_expand(path + '/');
else
m_metadir_path = rak::path_expand(path);
}

void
DownloadStore::set_path(const std::string& path) {
if (is_enabled())
Expand Down
3 changes: 3 additions & 0 deletions src/core/download_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class DownloadStore {
void enable(bool lock);
void disable();

const std::string& metadir_path() const { return m_metadir_path; }
void set_metadir_path(const std::string& path);
const std::string& path() const { return m_path; }
void set_path(const std::string& path);

Expand All @@ -77,6 +79,7 @@ class DownloadStore {
bool write_bencode(const std::string& filename, const torrent::Object& obj, uint32_t skip_mask);

std::string m_path;
std::string m_metadir_path;
utils::Lockfile m_lockfile;
};

Expand Down
3 changes: 3 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ parse_options(int argc, char** argv) {
optionParser.insert_option('b', std::bind(&rpc::call_command_set_string, "network.bind_address.set", std::placeholders::_1));
optionParser.insert_option('d', std::bind(&rpc::call_command_set_string, "directory.default.set", std::placeholders::_1));
optionParser.insert_option('i', std::bind(&rpc::call_command_set_string, "ip", std::placeholders::_1));
optionParser.insert_option('m', std::bind(&rpc::call_command_set_string, "metadir.path.set", std::placeholders::_1));
optionParser.insert_option('p', std::bind(&rpc::call_command_set_string, "network.port_range.set", std::placeholders::_1));
optionParser.insert_option('s', std::bind(&rpc::call_command_set_string, "session", std::placeholders::_1));

Expand Down Expand Up @@ -413,6 +414,7 @@ main(int argc, char** argv) {

CMD2_REDIRECT_GENERIC("directory", "directory.default.set");
CMD2_REDIRECT_GENERIC("session", "session.path.set");
CMD2_REDIRECT_GENERIC("metadir", "metadir.path.set");

CMD2_REDIRECT ("check_hash", "pieces.hash.on_completion.set");

Expand Down Expand Up @@ -646,6 +648,7 @@ print_help() {
std::cout << " -b <a.b.c.d> Bind the listening socket to this IP" << std::endl;
std::cout << " -i <a.b.c.d> Change the IP that is sent to the tracker" << std::endl;
std::cout << " -p <int>-<int> Set port range for incoming connections" << std::endl;
std::cout << " -m <directory> Save metadata files to this directory by default" << std::endl;
std::cout << " -d <directory> Save torrents to this directory by default" << std::endl;
std::cout << " -s <directory> Set the session directory" << std::endl;
std::cout << " -o key=opt,... Set options, see 'rtorrent.rc' file" << std::endl;
Expand Down