* Partial implementation of better detection and handling of deleted

files in a torrent.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1017 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2007-12-10 17:17:40 +00:00
parent 6db7ada26c
commit 71ac2cc8e1
3 changed files with 10 additions and 5 deletions
+1
View File
@@ -452,6 +452,7 @@ initialize_command_download() {
// value, it indicates the last time the torrent changed its state,
// resume/pause.
ADD_CD_VARIABLE_VALUE("state_changed", "rtorrent", "state_changed");
ADD_CD_VARIABLE_VALUE("state_counter", "rtorrent", "state_counter");
ADD_CD_VARIABLE_VALUE_PUBLIC("ignore_commands", "rtorrent", "ignore_commands");
ADD_CD_STRING_BI("connection_current", std::ptr_fun(&apply_d_connection_type), std::ptr_fun(&retrieve_d_connection_type));
+4 -1
View File
@@ -310,10 +310,13 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
if (!rtorrent->has_key_value("state") || rtorrent->get_key_value("state") > 1) {
rtorrent->insert_key("state", (int64_t)m_start);
rtorrent->insert_key("state_changed", cachedTime.seconds());
rtorrent->insert_key("state_counter", int64_t());
} else if (!rtorrent->has_key_value("state_changed") ||
rtorrent->get_key_value("state_changed") > cachedTime.seconds() || rtorrent->get_key_value("state_changed") == 0) {
rtorrent->get_key_value("state_changed") > cachedTime.seconds() || rtorrent->get_key_value("state_changed") == 0 ||
!rtorrent->has_key_value("state_counter") || (uint64_t)rtorrent->get_key_value("state_counter") > (1 << 20)) {
rtorrent->insert_key("state_changed", cachedTime.seconds());
rtorrent->insert_key("state_counter", int64_t());
}
rtorrent->insert_preserve_value("complete", 0);
+5 -4
View File
@@ -221,8 +221,7 @@ DownloadList::open_throw(Download* download) {
if (download->download()->is_open())
return;
// download->download()->open(torrent::Download::open_no_create);
download->download()->open(0);
download->download()->open(download->resume_flags());
std::for_each(slot_map_open().begin(), slot_map_open().end(), download_list_call(download));
}
@@ -395,6 +394,7 @@ DownloadList::resume(Download* download, int flags) {
// open_throw(download);
rpc::call_command("d.set_state_changed", cachedTime.seconds(), rpc::make_target(download));
rpc::call_command("d.set_state_counter", rpc::call_command_value("d.get_state_counter", rpc::make_target(download)) + 1, rpc::make_target(download));
if (download->is_done()) {
rpc::call_command("d.set_connection_current", rpc::call_command_void("d.get_connection_seed", rpc::make_target(download)), rpc::make_target(download));
@@ -452,6 +452,7 @@ DownloadList::pause(Download* download, int flags) {
std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download));
rpc::call_command("d.set_state_changed", cachedTime.seconds(), rpc::make_target(download));
rpc::call_command("d.set_state_counter", rpc::call_command_value("d.get_state_counter", rpc::make_target(download)), rpc::make_target(download));
// Save the state after all the slots, etc have been called so we
// include the modifications they may make.
@@ -522,7 +523,7 @@ DownloadList::hash_done(Download* download) {
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
if (rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
resume(download);
resume(download, download->resume_flags());
break;
@@ -623,7 +624,7 @@ DownloadList::confirm_finished(Download* download) {
throw torrent::internal_error("DownloadList::confirm_finished(...) download->resume_flags() != ~uint32_t().");
if (!download->is_active() && rpc::call_command_value("d.get_state", rpc::make_target(download)) == 1)
resume(download, torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
resume(download, torrent::Download::start_no_create | torrent::Download::start_skip_tracker | torrent::Download::start_keep_baseline);
}
}