diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml index 55650fc3..095368be 100644 --- a/doc/rtorrent.1.xml +++ b/doc/rtorrent.1.xml @@ -1012,7 +1012,7 @@ Adjust the send and receive buffer size for socket. - umask = 0644 + umask = 0022 Set the umask for this process, which is applied to all files created diff --git a/src/command_download.cc b/src/command_download.cc index 9a3539f7..be04fbee 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -175,6 +175,16 @@ apply_d_connection_type(core::Download* download, const std::string& name) { download->download()->set_connection_type(connType); } +void +apply_d_directory(core::Download* download, const std::string& name) { + if (!download->file_list()->is_multi_file()) + download->set_root_directory(name); + else if (name.empty() || *name.rbegin() == '/') + download->set_root_directory(name + download->download()->name()); + else + download->set_root_directory(name + "/" + download->download()->name()); +} + const char* retrieve_d_connection_type(core::Download* download) { switch (download->download()->connection_type()) { @@ -507,7 +517,9 @@ initialize_command_download() { ADD_CD_VALUE_UNI("tracker_focus", rak::on(std::mem_fun(&core::Download::tracker_list), std::mem_fun(&torrent::TrackerList::focus_index))); ADD_CD_VALUE_UNI("tracker_size", std::mem_fun(&core::Download::tracker_list_size)); - ADD_CD_STRING_BI("directory", std::mem_fun(&core::Download::set_root_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir))); + ADD_CD_STRING_BI("directory", std::ptr_fun(&apply_d_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir))); + ADD_CD_STRING_BI("directory_base", std::mem_fun(&core::Download::set_root_directory), rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::root_dir))); + ADD_CD_VALUE_BI("priority", std::mem_fun(&core::Download::set_priority), std::mem_fun(&core::Download::priority)); ADD_CD_STRING_UNI("priority_str", std::ptr_fun(&retrieve_d_priority_str)); diff --git a/src/core/download.cc b/src/core/download.cc index 749c6b88..48e98ba1 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -155,23 +155,12 @@ Download::receive_chunk_failed(__UNUSED uint32_t idx) { m_chunksFailed++; } -// Clean up. void Download::set_root_directory(const std::string& path) { torrent::FileList* fileList = m_download.file_list(); control->core()->download_list()->close_directly(this); - - if (path.empty()) { - fileList->set_root_dir("./" + (fileList->is_multi_file() ? m_download.name() : std::string())); - - } else { - std::string fullPath = rak::path_expand(path); - - fileList->set_root_dir(fullPath + - (*fullPath.rbegin() != '/' ? "/" : "") + - (fileList->is_multi_file() ? m_download.name() : std::string())); - } + fileList->set_root_dir(rak::path_expand(path)); bencode()->get_key("rtorrent").insert_key("directory", path); }