Keep starting when the DHT cache file is rejected

The router could throw while loading it, stopping rtorrent from starting at all.
This commit is contained in:
xirvik
2026-09-19 02:22:18 +00:00
committed by Jari Sundell
parent 80ae6a4590
commit 4e7129c71c
+9 -1
View File
@@ -4,6 +4,7 @@
#include <fstream>
#include <sstream>
#include <torrent/exceptions.h>
#include <torrent/object.h>
#include <torrent/object_stream.h>
#include <torrent/rate.h>
@@ -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();