mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 07:09:21 +00:00
Moved the sanity checks for 'd.directory.set' to 'Download::set_root_directory(path)' so that it always gets used.
This commit is contained in:
@@ -175,29 +175,6 @@ apply_d_delete_tied(core::Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
apply_d_directory(core::Download* download, const std::string& name) {
|
apply_d_directory(core::Download* download, const std::string& name) {
|
||||||
// If the download is open, hashed and has completed chunks make
|
|
||||||
// sure to verify that the download files are still present.
|
|
||||||
//
|
|
||||||
// This should ensure that no one tries to set the destination
|
|
||||||
// directory 'after' moving files. In cases where the user wants to
|
|
||||||
// override this behavior the download must first be closed or
|
|
||||||
// 'd.directory_base.set' may be used.
|
|
||||||
rak::file_stat file_stat;
|
|
||||||
torrent::FileList* file_list = download->file_list();
|
|
||||||
|
|
||||||
if (download->is_hash_checked() && file_list->completed_chunks() != 0 &&
|
|
||||||
|
|
||||||
(file_list->is_multi_file() ?
|
|
||||||
!file_list->is_root_dir_created() :
|
|
||||||
!file_stat.update(file_list->front()->frozen_path()))) {
|
|
||||||
|
|
||||||
download->set_message("Cannot change the directory of an open download after the files have been moved.");
|
|
||||||
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(download));
|
|
||||||
control->core()->download_list()->close_directly(download);
|
|
||||||
|
|
||||||
throw torrent::input_error("Cannot change the directory of an open download atter the files have been moved.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!download->file_list()->is_multi_file())
|
if (!download->file_list()->is_multi_file())
|
||||||
download->set_root_directory(name);
|
download->set_root_directory(name);
|
||||||
else if (name.empty() || *name.rbegin() == '/')
|
else if (name.empty() || *name.rbegin() == '/')
|
||||||
|
|||||||
+25
-3
@@ -39,8 +39,9 @@
|
|||||||
#include <sigc++/adaptors/bind.h>
|
#include <sigc++/adaptors/bind.h>
|
||||||
#include <sigc++/adaptors/hide.h>
|
#include <sigc++/adaptors/hide.h>
|
||||||
#include <sigc++/signal.h>
|
#include <sigc++/signal.h>
|
||||||
#include <rak/path.h>
|
#include <rak/file_stat.h>
|
||||||
#include <rak/functional.h>
|
#include <rak/functional.h>
|
||||||
|
#include <rak/path.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
#include <torrent/rate.h>
|
#include <torrent/rate.h>
|
||||||
#include <torrent/torrent.h>
|
#include <torrent/torrent.h>
|
||||||
@@ -172,10 +173,31 @@ Download::set_throttle_name(const std::string& throttleName) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Download::set_root_directory(const std::string& path) {
|
Download::set_root_directory(const std::string& path) {
|
||||||
torrent::FileList* fileList = m_download.file_list();
|
// If the download is open, hashed and has completed chunks make
|
||||||
|
// sure to verify that the download files are still present.
|
||||||
|
//
|
||||||
|
// This should ensure that no one tries to set the destination
|
||||||
|
// directory 'after' moving files. In cases where the user wants to
|
||||||
|
// override this behavior the download must first be closed or
|
||||||
|
// 'd.directory_base.set' may be used.
|
||||||
|
rak::file_stat file_stat;
|
||||||
|
torrent::FileList* file_list = m_download.file_list();
|
||||||
|
|
||||||
|
if (is_hash_checked() && file_list->completed_chunks() != 0 &&
|
||||||
|
|
||||||
|
(file_list->is_multi_file() ?
|
||||||
|
!file_list->is_root_dir_created() :
|
||||||
|
!file_stat.update(file_list->front()->frozen_path()))) {
|
||||||
|
|
||||||
|
set_message("Cannot change the directory of an open download after the files have been moved.");
|
||||||
|
rpc::call_command("d.state.set", (int64_t)0, rpc::make_target(this));
|
||||||
|
control->core()->download_list()->close_directly(this);
|
||||||
|
|
||||||
|
throw torrent::input_error("Cannot change the directory of an open download atter the files have been moved.");
|
||||||
|
}
|
||||||
|
|
||||||
control->core()->download_list()->close_directly(this);
|
control->core()->download_list()->close_directly(this);
|
||||||
fileList->set_root_dir(rak::path_expand(path));
|
file_list->set_root_dir(rak::path_expand(path));
|
||||||
|
|
||||||
bencode()->get_key("rtorrent").insert_key("directory", path);
|
bencode()->get_key("rtorrent").insert_key("directory", path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user