diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index de082a2bc..786045f9c 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1234,7 +1234,7 @@ TORRENT_VERSION_NAMESPACE_2 file_error_alert(aux::stack_allocator& alloc, error_code const& ec , string_view file, operation_t op, torrent_handle const& h); - TORRENT_DEFINE_ALERT(file_error_alert, 43) + TORRENT_DEFINE_ALERT_PRIO(file_error_alert, 43, alert_priority_high) static constexpr alert_category_t static_category = alert::status_notification | alert::error_notification diff --git a/src/torrent.cpp b/src/torrent.cpp index 818c31b2a..3cd82c6a7 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -7524,24 +7524,6 @@ bool is_downloading_state(int const st) return; } - // we might be finished already, in which case we should - // not switch to downloading mode. If all files are - // filtered, we're finished when we start. - if (m_state != torrent_status::finished - && m_state != torrent_status::seeding - && !m_seed_mode) - { - set_state(torrent_status::downloading); - } - - INVARIANT_CHECK; - - if (m_ses.alerts().should_post()) - { - m_ses.alerts().emplace_alert( - get_handle()); - } - // calling pause will also trigger the auto managed // recalculation // if we just got here by downloading the metadata, @@ -7578,6 +7560,24 @@ bool is_downloading_state(int const st) finished(); } + // we might be finished already, in which case we should + // not switch to downloading mode. If all files are + // filtered, we're finished when we start. + if (m_state != torrent_status::finished + && m_state != torrent_status::seeding + && !m_seed_mode) + { + set_state(torrent_status::downloading); + } + + INVARIANT_CHECK; + + if (m_ses.alerts().should_post()) + { + m_ses.alerts().emplace_alert( + get_handle()); + } + #ifndef TORRENT_DISABLE_EXTENSIONS for (auto& ext : m_extensions) { diff --git a/test/test_alert_types.cpp b/test/test_alert_types.cpp index b97ffbc52..65ce6baf8 100644 --- a/test/test_alert_types.cpp +++ b/test/test_alert_types.cpp @@ -111,7 +111,7 @@ TORRENT_TEST(alerts_types) TEST_ALERT_TYPE(torrent_resumed_alert, 40, 1, alert::status_notification); TEST_ALERT_TYPE(torrent_checked_alert, 41, 1, alert::status_notification); TEST_ALERT_TYPE(url_seed_alert, 42, 0, alert::peer_notification | alert::error_notification); - TEST_ALERT_TYPE(file_error_alert, 43, 0, alert::status_notification | alert::error_notification | alert::storage_notification); + TEST_ALERT_TYPE(file_error_alert, 43, 1, alert::status_notification | alert::error_notification | alert::storage_notification); TEST_ALERT_TYPE(metadata_failed_alert, 44, 0, alert::error_notification); TEST_ALERT_TYPE(metadata_received_alert, 45, 0, alert::status_notification); TEST_ALERT_TYPE(udp_error_alert, 46, 0, alert::error_notification); diff --git a/test/test_http_connection.cpp b/test/test_http_connection.cpp index 923a1d497..0ac4068ee 100644 --- a/test/test_http_connection.cpp +++ b/test/test_http_connection.cpp @@ -122,7 +122,7 @@ void run_test(std::string const& url, int size, int status, int connected std::shared_ptr h = std::make_shared(ios , res, &::http_handler_test, true, 1024*1024, &::http_connect_handler_test); - h->get(url, seconds(1), 0, &ps, 5, "test/user-agent", boost::none, resolver_flags{}, auth); + h->get(url, seconds(5), 0, &ps, 5, "test/user-agent", boost::none, resolver_flags{}, auth); ios.reset(); error_code e; ios.run(e);