Add http done/failed slots before starting request.

This commit is contained in:
Jari Sundell
2026-07-06 10:18:39 +02:00
committed by GitHub
parent cfad36bf12
commit 0494ce70c8
3 changed files with 12 additions and 7 deletions
+6 -2
View File
@@ -9,7 +9,8 @@
namespace core {
HttpQueue::iterator
HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream) {
HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream,
std::function<void()> done_fn, std::function<void(const std::string&)> failed_fn) {
auto itr = base_type::insert(end(), torrent::net::HttpGet(url, stream));
itr->set_max_file_size(15 << 20);
@@ -18,9 +19,12 @@ HttpQueue::insert(const std::string& url, std::shared_ptr<std::ostream> stream)
for (auto& slot : m_signal_insert)
slot(*itr);
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
itr->add_done_slot(torrent::this_thread::thread(), [this, itr]() { erase(itr); });
itr->add_failed_slot(torrent::this_thread::thread(), [this, itr](auto) { erase(itr); });
itr->add_done_slot(torrent::this_thread::thread(), std::move(done_fn));
itr->add_failed_slot(torrent::this_thread::thread(), std::move(failed_fn));
// TODO: Downloading http torrents doesn't seem to work.
// TODO: Quitting no longer works.