From ed8779a338cede7dbb339474bb89c00972870e38 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 6 Feb 2011 00:50:12 +0000 Subject: [PATCH] added option to not recheck on missing or incomplete resume data --- ChangeLog | 1 + docs/manual.rst | 8 ++++++ include/libtorrent/session_settings.hpp | 7 +++++ src/session_impl.cpp | 2 ++ src/storage.cpp | 35 ++++++++++++++----------- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2575bbe2a..22f9e26a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * added option to not recheck on missing or incomplete resume data * extended stats logging with statistics=on builds * added new session functions to more efficiently query torrent status * added alerts for added and removed torrents diff --git a/docs/manual.rst b/docs/manual.rst index cd31d19c5..2885bbf9a 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -4263,6 +4263,7 @@ session_settings bool enable_incoming_tcp; int max_pex_peers; bool ignore_resume_timestamps; + bool no_recheck_incomplete_resume; bool anonymous_mode; int tick_interval; int share_mode_target; @@ -4981,6 +4982,13 @@ It might be useful to set this to true if your network is faster than your disk, and it would be faster to redownload potentially missed pieces than to go through the whole storage to look for them. +``no_recheck_incomplete_resume`` determines if the storage should check +the whole files when resume data is incomplete or missing or whether +it should simply assume we don't have any of the data. By default, this +is determined by the existance of any of the files. By setting this setting +to true, the files won't be checked, but will go straight to download +mode. + ``anonymous_mode`` defaults to false. When set to true, the client tries to hide its identity to a certain degree. The peer-ID will no longer include the client's fingerprint. The user-agent will be reset to an diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 012e01e51..91149335d 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -233,6 +233,7 @@ namespace libtorrent , enable_incoming_tcp(true) , max_pex_peers(200) , ignore_resume_timestamps(false) + , no_recheck_incomplete_resume(false) , anonymous_mode(false) , tick_interval(100) , report_web_seed_downloads(true) @@ -912,6 +913,12 @@ namespace libtorrent // since the last session bool ignore_resume_timestamps; + // normally, if a resume file is incomplete (typically there's no + // "file sizes" field) the torrent is queued for a full check. If + // this settings is set to true, instead libtorrent will assume + // we have none of the files and go straight to download + bool no_recheck_incomplete_resume; + // when this is true, libtorrent will take actions to make sure any // privacy sensitive information is leaked out from the client. This // mode is assumed to be combined with using a proxy for all your diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c30779821..d0589ba77 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -331,6 +331,7 @@ namespace aux { TORRENT_SETTING(boolean, enable_incoming_tcp) TORRENT_SETTING(integer, max_pex_peers) TORRENT_SETTING(boolean, ignore_resume_timestamps) + TORRENT_SETTING(boolean, no_recheck_incomplete_resume) TORRENT_SETTING(boolean, anonymous_mode) TORRENT_SETTING(integer, tick_interval) TORRENT_SETTING(integer, upload_rate_limit) @@ -1491,6 +1492,7 @@ namespace aux { || m_settings.volatile_read_cache != s.volatile_read_cache || m_settings.no_atime_storage!= s.no_atime_storage || m_settings.ignore_resume_timestamps != s.ignore_resume_timestamps + || m_settings.no_recheck_incomplete_resume != s.no_recheck_incomplete_resume || m_settings.low_prio_disk != s.low_prio_disk) update_disk_io_thread = true; diff --git a/src/storage.cpp b/src/storage.cpp index cbad8a08c..7f21259fe 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -1971,25 +1971,28 @@ ret: int piece_manager::check_no_fastresume(error_code& error) { - bool has_files = m_storage->has_any_file(); - - if (m_storage->error()) - return fatal_disk_error; - - if (has_files) + bool has_files = false; + if (!m_storage->settings().no_recheck_incomplete_resume) { - m_state = state_full_check; - m_piece_to_slot.clear(); - m_piece_to_slot.resize(m_files.num_pieces(), has_no_slot); - m_slot_to_piece.clear(); - m_slot_to_piece.resize(m_files.num_pieces(), unallocated); - if (m_storage_mode == storage_mode_compact) + m_storage->has_any_file(); + if (m_storage->error()) + return fatal_disk_error; + + if (has_files) { - m_unallocated_slots.clear(); - m_free_slots.clear(); + m_state = state_full_check; + m_piece_to_slot.clear(); + m_piece_to_slot.resize(m_files.num_pieces(), has_no_slot); + m_slot_to_piece.clear(); + m_slot_to_piece.resize(m_files.num_pieces(), unallocated); + if (m_storage_mode == storage_mode_compact) + { + m_unallocated_slots.clear(); + m_free_slots.clear(); + } + TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces()); + return need_full_check; } - TORRENT_ASSERT(int(m_piece_to_slot.size()) == m_files.num_pieces()); - return need_full_check; } if (m_storage_mode == storage_mode_compact)