mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-15 05:36:17 +00:00
Potential fix to the issue of torrents remaining closed after final hashing.
This commit is contained in:
@@ -178,6 +178,8 @@ DownloadList::iterator
|
|||||||
DownloadList::insert(Download* download) {
|
DownloadList::insert(Download* download) {
|
||||||
iterator itr = base_type::insert(end(), download);
|
iterator itr = base_type::insert(end(), download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Inserting download.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(*itr)->data()->slot_initial_hash() = tr1::bind(&DownloadList::hash_done, this, download);
|
(*itr)->data()->slot_initial_hash() = tr1::bind(&DownloadList::hash_done, this, download);
|
||||||
(*itr)->data()->slot_download_done() = tr1::bind(&DownloadList::received_finished, this, download);
|
(*itr)->data()->slot_download_done() = tr1::bind(&DownloadList::received_finished, this, download);
|
||||||
@@ -208,6 +210,8 @@ DownloadList::erase(iterator itr) {
|
|||||||
if (itr == end())
|
if (itr == end())
|
||||||
throw torrent::internal_error("DownloadList::erase(...) could not find download.");
|
throw torrent::internal_error("DownloadList::erase(...) could not find download.");
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, (*itr)->info(), "->download_list: Erasing download.");
|
||||||
|
|
||||||
// Makes sure close doesn't restart hashing of this download.
|
// Makes sure close doesn't restart hashing of this download.
|
||||||
(*itr)->set_hash_failed(true);
|
(*itr)->set_hash_failed(true);
|
||||||
|
|
||||||
@@ -242,6 +246,8 @@ void
|
|||||||
DownloadList::open_throw(Download* download) {
|
DownloadList::open_throw(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Opening download.");
|
||||||
|
|
||||||
if (download->download()->info()->is_open())
|
if (download->download()->info()->is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -257,7 +263,6 @@ DownloadList::open_throw(Download* download) {
|
|||||||
void
|
void
|
||||||
DownloadList::close(Download* download) {
|
DownloadList::close(Download* download) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
close_throw(download);
|
close_throw(download);
|
||||||
|
|
||||||
} catch (torrent::local_error& e) {
|
} catch (torrent::local_error& e) {
|
||||||
@@ -267,6 +272,8 @@ DownloadList::close(Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::close_directly(Download* download) {
|
DownloadList::close_directly(Download* download) {
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Closing download directly.");
|
||||||
|
|
||||||
if (download->download()->info()->is_active()) {
|
if (download->download()->info()->is_active()) {
|
||||||
download->download()->stop(torrent::Download::stop_skip_tracker);
|
download->download()->stop(torrent::Download::stop_skip_tracker);
|
||||||
|
|
||||||
@@ -280,6 +287,7 @@ DownloadList::close_directly(Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::close_quick(Download* download) {
|
DownloadList::close_quick(Download* download) {
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Closing download quickly.");
|
||||||
close(download);
|
close(download);
|
||||||
|
|
||||||
// Make sure we cancel any tracker requests. This should rather be
|
// Make sure we cancel any tracker requests. This should rather be
|
||||||
@@ -293,6 +301,8 @@ void
|
|||||||
DownloadList::close_throw(Download* download) {
|
DownloadList::close_throw(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Closing download with throw.");
|
||||||
|
|
||||||
// When pause gets called it will clear the initial hash check state
|
// When pause gets called it will clear the initial hash check state
|
||||||
// and set hash failed. This should ensure hashing doesn't restart
|
// and set hash failed. This should ensure hashing doesn't restart
|
||||||
// until resume gets called.
|
// until resume gets called.
|
||||||
@@ -324,6 +334,8 @@ void
|
|||||||
DownloadList::resume(Download* download, int flags) {
|
DownloadList::resume(Download* download, int flags) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Resuming download: flags%0x.", flags);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (download->download()->info()->is_active())
|
if (download->download()->info()->is_active())
|
||||||
@@ -417,6 +429,8 @@ void
|
|||||||
DownloadList::pause(Download* download, int flags) {
|
DownloadList::pause(Download* download, int flags) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Pausing download: flags%0x.", flags);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
download->set_resume_flags(~uint32_t());
|
download->set_resume_flags(~uint32_t());
|
||||||
@@ -464,8 +478,9 @@ void
|
|||||||
DownloadList::check_hash(Download* download) {
|
DownloadList::check_hash(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
try {
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Checking hash.");
|
||||||
|
|
||||||
|
try {
|
||||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -480,6 +495,8 @@ void
|
|||||||
DownloadList::hash_done(Download* download) {
|
DownloadList::hash_done(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Hash done.");
|
||||||
|
|
||||||
if (download->is_hash_checking() || download->is_active())
|
if (download->is_hash_checking() || download->is_active())
|
||||||
throw torrent::internal_error("DownloadList::hash_done(...) download in invalid state.");
|
throw torrent::internal_error("DownloadList::hash_done(...) download in invalid state.");
|
||||||
|
|
||||||
@@ -554,6 +571,8 @@ void
|
|||||||
DownloadList::hash_queue(Download* download, int type) {
|
DownloadList::hash_queue(Download* download, int type) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Hash queue.");
|
||||||
|
|
||||||
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
if (rpc::call_command_value("d.hashing", rpc::make_target(download)) != Download::variable_hashing_stopped)
|
||||||
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
|
throw torrent::internal_error("DownloadList::hash_queue(...) hashing already queued.");
|
||||||
|
|
||||||
@@ -583,6 +602,8 @@ void
|
|||||||
DownloadList::received_finished(Download* download) {
|
DownloadList::received_finished(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Received finished.");
|
||||||
|
|
||||||
if (rpc::call_command_value("pieces.hash.on_completion"))
|
if (rpc::call_command_value("pieces.hash.on_completion"))
|
||||||
// Set some 'checking_finished_thingie' variable to make hash_done
|
// Set some 'checking_finished_thingie' variable to make hash_done
|
||||||
// trigger correctly, also so it can bork on missing data.
|
// trigger correctly, also so it can bork on missing data.
|
||||||
@@ -596,6 +617,8 @@ void
|
|||||||
DownloadList::confirm_finished(Download* download) {
|
DownloadList::confirm_finished(Download* download) {
|
||||||
check_contains(download);
|
check_contains(download);
|
||||||
|
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Confirming finished.");
|
||||||
|
|
||||||
if (download->download()->info()->is_meta_download())
|
if (download->download()->info()->is_meta_download())
|
||||||
return process_meta_download(download);
|
return process_meta_download(download);
|
||||||
|
|
||||||
@@ -642,7 +665,7 @@ DownloadList::confirm_finished(Download* download) {
|
|||||||
|
|
||||||
DL_TRIGGER_EVENT(download, "event.download.finished");
|
DL_TRIGGER_EVENT(download, "event.download.finished");
|
||||||
|
|
||||||
if (find(infohash) != end())
|
if (find(infohash) == end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if (download->resume_flags() != ~uint32_t())
|
// if (download->resume_flags() != ~uint32_t())
|
||||||
@@ -667,6 +690,8 @@ DownloadList::confirm_finished(Download* download) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
DownloadList::process_meta_download(Download* download) {
|
DownloadList::process_meta_download(Download* download) {
|
||||||
|
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "->download_list: Processing meta download.");
|
||||||
|
|
||||||
rpc::call_command("d.stop", torrent::Object(), rpc::make_target(download));
|
rpc::call_command("d.stop", torrent::Object(), rpc::make_target(download));
|
||||||
rpc::call_command("d.close", torrent::Object(), rpc::make_target(download));
|
rpc::call_command("d.close", torrent::Object(), rpc::make_target(download));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user