Skip to content

Commit

Permalink
Add trackers.delay_scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
Elegant996 committed May 23, 2023
1 parent 370e15a commit 21e50d2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/core/download_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class DownloadFactory {
m_start = v;
}

bool get_init_load() const {
return m_initLoad;
}
void set_init_load(bool v) {
m_initLoad = v;
}

bool print_log() const {
return m_printLog;
}
Expand Down Expand Up @@ -103,6 +110,7 @@ class DownloadFactory {
bool m_printLog{ true };
bool m_immediate{ false };
bool m_isFile{ false };
bool m_initLoad{ false };

command_list_type m_commands;
torrent::Object::map_type m_variables;
Expand Down
1 change: 1 addition & 0 deletions src/command_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ initialize_command_tracker() {
CMD2_ANY_VALUE("trackers.disable", [](const auto&, const auto&) {
return apply_enable_trackers(int64_t(0));
});
CMD2_VAR_BOOL("trackers.delay_scrape", false);
CMD2_VAR_VALUE("trackers.numwant", -1);
CMD2_VAR_BOOL("trackers.use_udp", true);

Expand Down
4 changes: 4 additions & 0 deletions src/core/download_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ DownloadFactory::receive_success() {
if (!rpc::call_command_value("trackers.use_udp"))
download->enable_udp_trackers(false);

// Skip forcing trackers to scrape when rtorrent starts
if (m_initLoad && rpc::call_command_value("trackers.delay_scrape"))
download->set_resume_flags(torrent::Download::start_skip_tracker);

// Check first if we already have these values set in the session
// torrent, so that it is safe to change the values.
//
Expand Down
2 changes: 2 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ load_session_torrents() {

// Replace with session torrent flag.
f->set_session(true);
f->set_init_load(true);
f->set_immediate(true);
f->slot_finished([f, &progress_bar, entries_size]() {
if (control->is_shutdown_received()) {
Expand Down Expand Up @@ -199,6 +200,7 @@ load_arg_torrents(char** first, char** last) {

// Replace with session torrent flag.
f->set_start(true);
f->set_init_load(true);
f->slot_finished([f]() { delete f; });
f->load(*first);
f->commit();
Expand Down

0 comments on commit 21e50d2

Please sign in to comment.