From 4e7129c71c3da0248327593202da4da3a1921b91 Mon Sep 17 00:00:00 2001 From: xirvik Date: Sat, 19 Sep 2026 02:22:18 +0000 Subject: [PATCH] Keep starting when the DHT cache file is rejected The router could throw while loading it, stopping rtorrent from starting at all. --- src/core/dht_manager.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/dht_manager.cc b/src/core/dht_manager.cc index 611ec72c..d9f3d336 100644 --- a/src/core/dht_manager.cc +++ b/src/core/dht_manager.cc @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,14 @@ DhtManager::load_dht_cache() { LT_LOG("could not open cache file (path:%s)", cache_filename.c_str()); } - torrent::runtime::network_manager()->dht_controller()->initialize(cache); + try { + torrent::runtime::network_manager()->dht_controller()->initialize(cache); + + } catch (const torrent::base_error& e) { + LT_LOG_ERROR("cache file rejected, discarding (path:%s errmsg:%s)", cache_filename.c_str(), e.what()); + + torrent::runtime::network_manager()->dht_controller()->initialize(torrent::Object::create_map()); + } if (m_start == dht_on) start_dht();