mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-05 11:24:15 +00:00
- Fixed crash when dht_state is missing
This commit is contained in:
parent
5133931302
commit
78409570a9
@ -738,12 +738,15 @@ void bittorrent::saveSessionState() {
|
|||||||
bool bittorrent::enableDHT(bool b) {
|
bool bittorrent::enableDHT(bool b) {
|
||||||
if(b) {
|
if(b) {
|
||||||
if(!DHTEnabled) {
|
if(!DHTEnabled) {
|
||||||
boost::filesystem::ifstream dht_state_file((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary);
|
|
||||||
dht_state_file.unsetf(std::ios_base::skipws);
|
|
||||||
entry dht_state;
|
entry dht_state;
|
||||||
try{
|
QString dht_state_path = misc::qBittorrentPath()+QString::fromUtf8("dht_state");
|
||||||
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
|
if(QFile::exists(dht_state_path)) {
|
||||||
}catch (std::exception&) {}
|
boost::filesystem::ifstream dht_state_file(dht_state_path.toUtf8().data(), std::ios_base::binary);
|
||||||
|
dht_state_file.unsetf(std::ios_base::skipws);
|
||||||
|
try{
|
||||||
|
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
|
||||||
|
}catch (std::exception&) {}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
s->start_dht(dht_state);
|
s->start_dht(dht_state);
|
||||||
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
|
s->add_dht_router(std::make_pair(std::string("router.bittorrent.com"), 6881));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user